This commit adds a callback route to handle omniauth failure and removes a few unneccessary entries in en.yml

This commit is contained in:
Jesse Pollak 2013-02-14 11:11:13 -08:00
parent 9eb5c2a66a
commit ad5a5b4866
6 changed files with 84 additions and 54 deletions

View File

@ -22,6 +22,11 @@ class Users::OmniauthCallbacksController < ApplicationController
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)
data = auth_token[:info]

View 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>

View File

@ -1,4 +1,3 @@
require 'openid/store/filesystem'
require 'openssl'
require 'openid_redis_store'

View File

@ -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."
errors: "%{errors}"
not_available: "Not available. Try %{suggestion}?"
omniauth_error: "Sorry, there was an error authorizing your %{strategy} account. Perhaps you did not approve authorization?"
user:
username:

View File

@ -115,6 +115,7 @@ Discourse::Application.routes.draw do
resources :categories
match "/auth/:provider/callback", to: "users/omniauth_callbacks#complete"
match "/auth/failure", to: "users/omniauth_callbacks#failure"
get 'twitter/frame' => 'twitter#frame'
get 'twitter/complete' => 'twitter#complete'

View 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