mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Implements iChain authentication
This commit is contained in:
parent
15c6ed127f
commit
49d565def2
21 changed files with 269 additions and 126 deletions
|
|
@ -11,11 +11,13 @@ module Users
|
|||
|
||||
def handle(provider)
|
||||
auth_hash = request.env['omniauth.auth']
|
||||
uid = auth_hash[:uid]
|
||||
openid = Openid.find_for_oauth(auth_hash) # Get or create openid
|
||||
# If openid exists and is associated with a user, sign in with associated user,
|
||||
# even if the email of the associated user and the email of the provided openid are different
|
||||
unless (user = openid.user)
|
||||
user = User.find_for_auth(auth_hash, current_user) # Get or create users
|
||||
user.username = "#{uid}@#{provider}" if user.username.blank?
|
||||
end
|
||||
|
||||
begin
|
||||
|
|
@ -28,7 +30,8 @@ module Users
|
|||
sign_in user
|
||||
redirect_to root_path, notice: user.email + " signed in successfully with #{provider}"
|
||||
rescue => e
|
||||
redirect_back_or_to new_user_registration_path, alert: 'Failed' + e.message
|
||||
flash[:error] = e.message
|
||||
redirect_back_or_to new_user_registration_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue