mirror of
https://github.com/discourse/discourse.git
synced 2025-04-02 08:16:45 +08:00
Merge pull request #162 from jessepollak/omniauth-failure
Adds failure callback for omniauth
This commit is contained in:
commit
3cdf89d052
@ -22,6 +22,11 @@ class Users::OmniauthCallbacksController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def failure
|
||||||
|
flash[:error] = I18n.t("login.omniauth_error", strategy: params[:strategy].titleize)
|
||||||
|
render :layout => 'no_js'
|
||||||
|
end
|
||||||
|
|
||||||
def create_or_sign_on_user_using_twitter(auth_token)
|
def create_or_sign_on_user_using_twitter(auth_token)
|
||||||
|
|
||||||
data = auth_token[:info]
|
data = auth_token[:info]
|
||||||
|
11
app/views/users/omniauth_callbacks/failure.html.erb
Normal file
11
app/views/users/omniauth_callbacks/failure.html.erb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<div id="simple-container">
|
||||||
|
<%if flash[:error]%>
|
||||||
|
<div class='alert alert-error'>
|
||||||
|
<%=flash[:error]%>
|
||||||
|
</div>
|
||||||
|
<%else%>
|
||||||
|
<div class='alert alert-error'>
|
||||||
|
Something went wrong processing your log in, please try again.
|
||||||
|
</div>
|
||||||
|
<%end%>
|
||||||
|
</div>
|
@ -1,4 +1,3 @@
|
|||||||
require 'openid/store/filesystem'
|
|
||||||
require 'openssl'
|
require 'openssl'
|
||||||
require 'openid_redis_store'
|
require 'openid_redis_store'
|
||||||
|
|
||||||
|
@ -420,6 +420,8 @@ en:
|
|||||||
not_activated: "You can't log in yet. We sent an activation email to you. Please follow the instructions in the email to activate your account."
|
not_activated: "You can't log in yet. We sent an activation email to you. Please follow the instructions in the email to activate your account."
|
||||||
errors: "%{errors}"
|
errors: "%{errors}"
|
||||||
not_available: "Not available. Try %{suggestion}?"
|
not_available: "Not available. Try %{suggestion}?"
|
||||||
|
omniauth_error: "Sorry, there was an error authorizing your %{strategy} account. Perhaps you did not approve authorization?"
|
||||||
|
|
||||||
|
|
||||||
user:
|
user:
|
||||||
username:
|
username:
|
||||||
|
@ -115,6 +115,7 @@ Discourse::Application.routes.draw do
|
|||||||
resources :categories
|
resources :categories
|
||||||
|
|
||||||
match "/auth/:provider/callback", to: "users/omniauth_callbacks#complete"
|
match "/auth/:provider/callback", to: "users/omniauth_callbacks#complete"
|
||||||
|
match "/auth/failure", to: "users/omniauth_callbacks#failure"
|
||||||
|
|
||||||
get 'twitter/frame' => 'twitter#frame'
|
get 'twitter/frame' => 'twitter#frame'
|
||||||
get 'twitter/complete' => 'twitter#complete'
|
get 'twitter/complete' => 'twitter#complete'
|
||||||
|
12
spec/views/omniauth_callbacks/failure.html.erb_spec.rb
Normal file
12
spec/views/omniauth_callbacks/failure.html.erb_spec.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe "users/omniauth_callbacks/failure.html.erb" do
|
||||||
|
|
||||||
|
it "renders the failure page" do
|
||||||
|
flash[:error] = I18n.t("login.omniauth_error", strategy: 'test')
|
||||||
|
render
|
||||||
|
|
||||||
|
rendered.match(I18n.t("login.omniauth_error", strategy: 'test')).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user