FEATURE: Localize SSO error messages

This commit is contained in:
Sam 2014-11-24 12:15:51 +11:00
parent 1ad38e05b2
commit 9e1e3df6c9
2 changed files with 10 additions and 4 deletions

View File

@ -36,7 +36,7 @@ class SessionController < ApplicationController
sso = DiscourseSingleSignOn.parse(request.query_string) sso = DiscourseSingleSignOn.parse(request.query_string)
if !sso.nonce_valid? if !sso.nonce_valid?
render text: "Timeout expired, please try logging in again.", status: 500 render text: I18n.t("sso.timeout_expired"), status: 500
return return
end end
@ -46,13 +46,13 @@ class SessionController < ApplicationController
begin begin
if user = sso.lookup_or_create_user if user = sso.lookup_or_create_user
if SiteSetting.must_approve_users? && !user.approved? if SiteSetting.must_approve_users? && !user.approved?
# TODO: need an awaiting approval message here render text: I18n.t("sso.account_not_approved"), status: 403
else else
log_on_user user log_on_user user
end end
redirect_to return_path redirect_to return_path
else else
render text: "unable to log on user", status: 500 render text: I18n.t("sso.not_found"), status: 500
end end
rescue => e rescue => e
details = {} details = {}
@ -61,7 +61,7 @@ class SessionController < ApplicationController
end end
Discourse.handle_exception(e, details) Discourse.handle_exception(e, details)
render text: "unable to log on user contact site admin (see /logs for more info)", status: 500 render text: I18n.t("sso.unknown_error"), status: 500
end end
end end

View File

@ -1060,6 +1060,12 @@ en:
topic: 'Results' topic: 'Results'
user: 'Users' user: 'Users'
sso:
not_found: "Unable to lookup or create account, contact site admin"
account_not_approved: "Account is pending approval, you will receive an email notification once approved"
unknown_error: "Error updating information, contact site admin"
timeout_expired: "Account login timed out, please try logging in again"
original_poster: "Original Poster" original_poster: "Original Poster"
most_posts: "Most Posts" most_posts: "Most Posts"
most_recent_poster: "Most Recent Poster" most_recent_poster: "Most Recent Poster"