Skip to content
Snippets Groups Projects
Verified Commit 27358dc4 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

user model: add find_with_omniauth/create_with_omniauth

parent be7185c4
No related branches found
No related tags found
1 merge request!21OBS SSO implementation
...@@ -283,6 +283,31 @@ class User < ActiveRecord::Base ...@@ -283,6 +283,31 @@ class User < ActiveRecord::Base
end end
end end
def self.find_with_omniauth(auth)
if auth
email = auth['info']['email']
user = find_by_email(email)
if user
user.mark_login!
return user
end
end
end
def self.create_with_omniauth(auth, login)
provider = CONFIG['sso_auth'][auth['provider']]['description'] || OmniAuth::Utils.camelize(auth['provider'])
email = auth['info']['email']
logger.debug("Creating OmniAuth user for #{provider}")
logger.debug("Email: #{email}")
logger.debug("Name : #{auth['info']['name']}")
return create_external_user(login: login,
email: email,
realname: auth['info']['name'],
password_hash_type: 'invalid',
adminnote: "User created via #{provider}")
end
# This method checks whether the given value equals the password when # This method checks whether the given value equals the password when
# hashed with this user's password hash type. Returns a boolean. # hashed with this user's password hash type. Returns a boolean.
def password_equals?(value) def password_equals?(value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment