Commit 49c9e8ec authored by Marin Jankovski's avatar Marin Jankovski Committed by Dmitriy Zaporozhets

Use an error page when oauth fails.

parent f40e87a0
......@@ -31,6 +31,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
end
def omniauth_error
@provider = params[:provider]
@error = params[:error]
render 'errors/omniauth_error', layout: "errors", status: 422
end
private
def handle_omniauth
......@@ -54,7 +60,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
else
if errors
error_message = errors.map{ |attribute, message| "#{attribute} #{message}" }.join(", ")
flash[:notice] = "There was a problem creating your account. #{error_message}"
redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return
else
flash[:notice] = "There's no such user!"
end
......
......@@ -160,6 +160,9 @@ Gitlab::Application.routes.draw do
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :users_sessions }
devise_scope :user do
get "/users/auth/:provider/omniauth_error" => "omniauth_callbacks#omniauth_error", as: :omniauth_error
end
#
# Project Area
#
......
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