Skip to content

Commit

Permalink
Fix for latest OAuth and Redmine
Browse files Browse the repository at this point in the history
  • Loading branch information
geordee committed Dec 27, 2016
1 parent f74b180 commit 0c0a830
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/controllers/redmine_oauth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def oauth_azure_callback
user_info = JWT.decode(token.token, nil, false)
logger.error user_info

email = user_info['unique_name']
email = user_info.first['unique_name']

if email
checked_try_to_login email, user_info
checked_try_to_login email, user_info.first
else
flash[:error] = l(:notice_no_verified_email_we_could_use)
redirect_to signin_path
Expand All @@ -47,7 +47,9 @@ def try_to_login email, info
params[:back_url] = session[:back_url]
session.delete(:back_url)

user = User.find_or_initialize_by_mail(email)
user = User.joins(:email_addresses)
.where('email_addresses.address' => email, 'email_addresses.is_default' => true)
.first_or_initialize
if user.new_record?
# Self-registration off
redirect_to(home_url) && return unless Setting.self_registration?
Expand Down

0 comments on commit 0c0a830

Please sign in to comment.