Module: Bpluser::User::ClassMethods
- Defined in:
- app/models/bpluser/user.rb
Instance Method Summary collapse
- #find_for_facebook_oauth(auth, signed_in_resource = nil) ⇒ Object
- #find_for_ldap_oauth(auth_response, signed_in_resource = nil) ⇒ Object
- #find_for_local_auth(auth, signed_in_resource = nil) ⇒ Object
- #find_for_polaris_oauth(auth_response, signed_in_resource = nil) ⇒ Object
Instance Method Details
#find_for_facebook_oauth(auth, signed_in_resource = nil) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/models/bpluser/user.rb', line 90 def find_for_facebook_oauth(auth, signed_in_resource=nil) user = User.where(:provider => auth.provider, :uid => auth.uid).first unless user user = User.create(display_name:auth.extra.raw_info.name, uid:auth.uid, provider:auth.provider, username:auth.info.nickname, email:auth.info.email, password:Devise.friendly_token[0,20] , first_name:auth.extra.raw_info.first_name, last_name:auth.extra.raw_info.last_name ) end user end |
#find_for_ldap_oauth(auth_response, signed_in_resource = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/bpluser/user.rb', line 20 def find_for_ldap_oauth(auth_response, signed_in_resource=nil) ldap_raw_details = auth_response[:extra][:raw_info] ldap_info_details = auth_response[:info] user = User.where(:provider => auth_response.provider, :uid => ldap_raw_details.samaccountname[0].downcase).first #first_name:ldap_info_details.first_name, #last_name:ldap_info_details.last_name, unless user user = User.create(provider:auth_response.provider, uid:ldap_raw_details.samaccountname[0].downcase, username:ldap_raw_details.samaccountname[0].downcase, email:ldap_raw_details.mail[0].to_s.downcase, password:Devise.friendly_token[0,20], display_name: ldap_info_details.first_name + " " + ldap_info_details.last_name, first_name: ldap_info_details.first_name, last_name: ldap_info_details.last_name ) end groups = user.ldap_groups groups.each do |group| if(group == "Repository Administrators") superuser_role = Role.where(:name=>'superuser').first if(superuser_role == nil) superuser_role = Role.create(:name=>"superuser") end user.roles << superuser_role unless user.roles.include?(superuser_role) user.save! admin_role = Role.where(:name=>'admin').first if(admin_role == nil) admin_role = Role.create(:name=>"admin") end user.roles << admin_role unless user.roles.include?(admin_role) user.save! end end user end |
#find_for_local_auth(auth, signed_in_resource = nil) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'app/models/bpluser/user.rb', line 106 def find_for_local_auth(auth, signed_in_resource=nil) user = User.where(:provider => auth.provider, :uid => auth.uid).first unless user user = User.create(display_name:auth.full_name, uid:auth.uid, provider:auth.provider, username:auth.uid, email:auth.email, password:auth.password, first_name:auth.first_name, last_name:auth.last_name ) end user end |
#find_for_polaris_oauth(auth_response, signed_in_resource = nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/bpluser/user.rb', line 64 def find_for_polaris_oauth(auth_response, signed_in_resource=nil) polaris_raw_details = auth_response[:extra][:raw_info] polaris_info_details = auth_response[:info] user = User.where(:provider => auth_response.provider, :uid => auth_response[:uid]).first #first_name:ldap_info_details.first_name, #last_name:ldap_info_details.last_name, unless user #For some reason, User.create has no id set despite that intending to be autocreated. Unsure what is up with that. So trying this. user = User.new(provider:auth_response.provider, uid:auth_response[:uid], username:polaris_info_details[:first_name], email:polaris_info_details[:email], password:Devise.friendly_token[0,20], display_name:polaris_info_details[:first_name] + " " + polaris_info_details[:last_name], first_name: polaris_info_details[:first_name], last_name: polaris_info_details[:last_name] ) user.save! end user end |