Skip to content
Snippets Groups Projects
Commit fc430d6e authored by Дмитрий Коваленок's avatar Дмитрий Коваленок
Browse files

reactoring method oauth_google_callback from the RedmineOmniauthController

parent 2d36aedd
No related branches found
No related tags found
No related merge requests found
...@@ -16,9 +16,13 @@ class RedmineOmniauthController < AccountController ...@@ -16,9 +16,13 @@ class RedmineOmniauthController < AccountController
# Self-registration off # Self-registration off
redirect_to(home_url) && return unless Setting.self_registration? redirect_to(home_url) && return unless Setting.self_registration?
# Create on the fly # Create on the fly
user.login = info["email"].match(/(.+)@/)[1] unless info["email"].nil?
user.mail = info["email"] unless info["email"].nil?
user.firstname, user.lastname = info["name"].split(' ') unless info['name'].nil? user.firstname, user.lastname = info["name"].split(' ') unless info['name'].nil?
user.firstname ||= info[:given_name]
user.lastname ||= info[:family_name]
user.mail = info["email"]
login = info["email"].match(/(.+)@/) unless info["email"].nil?
user.login = login[1] if login
user.login ||= [user.firstname, user.lastname]*"."
user.random_password user.random_password
user.register user.register
...@@ -44,6 +48,9 @@ class RedmineOmniauthController < AccountController ...@@ -44,6 +48,9 @@ class RedmineOmniauthController < AccountController
account_pending account_pending
end end
end end
else
flash[:error] = l(:notice_unable_to_obtain_google_credentials)
redirect_to signin_path
end end
end end
......
# English strings go here for Rails i18n # English strings go here for Rails i18n
en: en:
my_label: "My label" notice_unable_to_obtain_google_credentials: "Unable to obtain credentials from Google. You have not yet registered."
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment