Commit 3bef58b4 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Added Geo flash information on first login

parent 7e7f552c
class Oauth::GeoAuthController < ActionController::Base class Oauth::GeoAuthController < ActionController::Base
include ActionView::Helpers::UrlHelper
rescue_from Gitlab::Geo::OauthApplicationUndefinedError, with: :undefined_oauth_application rescue_from Gitlab::Geo::OauthApplicationUndefinedError, with: :undefined_oauth_application
rescue_from OAuth2::Error, with: :auth rescue_from OAuth2::Error, with: :auth
...@@ -25,9 +26,7 @@ class Oauth::GeoAuthController < ActionController::Base ...@@ -25,9 +26,7 @@ class Oauth::GeoAuthController < ActionController::Base
user = User.find_by(id: remote_user['id']) user = User.find_by(id: remote_user['id'])
if user && sign_in(user, bypass: true) if user && sign_in(user, bypass: true)
session[:access_token] = token after_sign_in_with_gitlab(token, oauth.get_oauth_state_return_to)
return_to = oauth.get_oauth_state_return_to
redirect_to(return_to || root_path)
else else
invalid_credentials invalid_credentials
end end
...@@ -46,6 +45,14 @@ class Oauth::GeoAuthController < ActionController::Base ...@@ -46,6 +45,14 @@ class Oauth::GeoAuthController < ActionController::Base
private private
def after_sign_in_with_gitlab(token, return_to)
primary_node = link_to('primary node', Gitlab::Geo.primary_node.url)
flash[:notice] = "You are in a Geo secondary node (read-only). To make any change you must visit the #{primary_node}.".html_safe
session[:access_token] = token
redirect_to(return_to || root_path)
end
def invalid_credentials def invalid_credentials
@error = 'Cannot find user to login. Your account may have been deleted.' @error = 'Cannot find user to login. Your account may have been deleted.'
render :error, layout: 'errors' render :error, layout: 'errors'
......
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