Commit 863b2ece authored by Ilya Kolodnik's avatar Ilya Kolodnik

add error processing when access denied

parent 69d314b1
......@@ -14,19 +14,24 @@ class RedmineOauthController < AccountController
end
def oauth_google_callback
token = oauth_client.auth_code.get_token(params[:code], :redirect_uri => oauth_google_callback_url)
result = token.get('https://www.googleapis.com/oauth2/v1/userinfo')
info = JSON.parse(result.body)
if info && info["verified_email"]
if allowed_domain_for?(info["email"])
try_to_login info
if params[:error]
flash[:error] = l(:notice_access_denied)
redirect_to signin_path
else
token = oauth_client.auth_code.get_token(params[:code], :redirect_uri => oauth_google_callback_url)
result = token.get('https://www.googleapis.com/oauth2/v1/userinfo')
info = JSON.parse(result.body)
if info && info["verified_email"]
if allowed_domain_for?(info["email"])
try_to_login info
else
flash[:error] = l(:notice_domain_not_allowed, :domain => parse_email(info["email"])[:domain])
redirect_to signin_path
end
else
flash[:error] = l(:notice_domain_not_allowed, :domain => parse_email(info["email"])[:domain])
flash[:error] = l(:notice_unable_to_obtain_google_credentials)
redirect_to signin_path
end
else
flash[:error] = l(:notice_unable_to_obtain_google_credentials)
redirect_to signin_path
end
end
......
en:
notice_unable_to_obtain_google_credentials: "Unable to obtain credentials from Google."
notice_domain_not_allowed: "You can not login using %{domain} domain."
notice_access_denied: "You must allow to use you Google credentials to enter this site."
login_via_google: "Login via Google"
ru:
notice_unable_to_obtain_google_credentials: "Не удалось получить данные от Google."
notice_domain_not_allowed: "Вы не можете войти в систему при помощи домена %{domain}."
login_via_google: "Войти с Google"
\ No newline at end of file
notice_access_denied: "Для корректного входа необходимо разрешить приложению доступ к аккаунту."
login_via_google: "Войти с Google"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment