From fc430d6e627916187816dcf3e16da7948f6fdee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9A=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B5=D0=BD=D0=BE=D0=BA?= <dmitry.kovalenok@twinslash.com> Date: Tue, 30 Oct 2012 19:27:11 +0300 Subject: [PATCH] reactoring method oauth_google_callback from the RedmineOmniauthController --- app/controllers/redmine_omniauth_controller.rb | 11 +++++++++-- config/locales/en.yml | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/redmine_omniauth_controller.rb b/app/controllers/redmine_omniauth_controller.rb index 3b8b71a..7440eaa 100644 --- a/app/controllers/redmine_omniauth_controller.rb +++ b/app/controllers/redmine_omniauth_controller.rb @@ -16,9 +16,13 @@ class RedmineOmniauthController < AccountController # Self-registration off redirect_to(home_url) && return unless Setting.self_registration? # 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 ||= 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.register @@ -44,6 +48,9 @@ class RedmineOmniauthController < AccountController account_pending end end + else + flash[:error] = l(:notice_unable_to_obtain_google_credentials) + redirect_to signin_path end end diff --git a/config/locales/en.yml b/config/locales/en.yml index c55090a..186006c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,3 +1,3 @@ # English strings go here for Rails i18n 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 -- GitLab