Module: Adauth::UserModel::ClassMethods

Defined in:
lib/adauth/user_model.rb

Overview

Class methods for the UserModel

Instance Method Summary collapse

Instance Method Details

#create_user_with_adauth(adauth_user) ⇒ Object

Creates a user record from an instance of Adauth::User

Called as:

YourUserModel.create_user_with_adauth(AdauthUserInstance)

Takes the Adauth::User input and creates a user record with matching details



66
67
68
69
70
71
72
73
# File 'lib/adauth/user_model.rb', line 66

def create_user_with_adauth(adauth_user)
	create! do |user|
		user. = adauth_user..gsub(/\"|\[|\]/, "")
		user.group_strings = adauth_user.groups.join(", ")
		user.ou_strings = adauth_user.ous.join(", ")
		user.name = adauth_user.name.gsub(/\"|\[|\]/, "")
	end
end

#return_and_create_with_adauth(adauth_user) ⇒ Object

Used during the login process to return the users database record.

Takes an instance of Adauth::User as an input

Called as

YourUserModel.return_and_create_with_adauth(AdauthUserInstance)

If the user has no user record in the database one will be created. All the details on the record (new and old) will be updated to the lastest details from the AD server



54
55
56
57
58
# File 'lib/adauth/user_model.rb', line 54

def return_and_create_with_adauth(adauth_user)
    user = ((adauth_user..gsub(/\"|\[|\]/, "")) || create_user_with_adauth(adauth_user))
    user.update_from_adauth(adauth_user)
    return user
end