From ef7ea1a855f6c8cf325a162e95a0186b3ec32087 Mon Sep 17 00:00:00 2001 From: augier Date: Mon, 23 Nov 2015 11:02:56 +0100 Subject: [PATCH] General text error + CSS styling Minor merge conflict fix by theworldbright --- app/assets/stylesheets/mobile/mobile.scss | 1 + .../mobile/openid_connect_error_page.scss | 9 +++++++++ .../openid_connect/authorizations_controller.rb | 15 ++++++++++----- .../api/openid_connect/error/_error.html.haml | 6 +++++- .../api/openid_connect/error/error.mobile.haml | 7 +++++++ config/locales/diaspora/en.yml | 3 +++ 6 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 app/assets/stylesheets/mobile/openid_connect_error_page.scss diff --git a/app/assets/stylesheets/mobile/mobile.scss b/app/assets/stylesheets/mobile/mobile.scss index 4ad15e0e3..5b76b4acb 100644 --- a/app/assets/stylesheets/mobile/mobile.scss +++ b/app/assets/stylesheets/mobile/mobile.scss @@ -13,6 +13,7 @@ @import "mobile/settings"; @import "mobile/stream_element"; @import "mobile/comments"; +@import 'mobile/openid_connect_error_page'; @import 'typography'; diff --git a/app/assets/stylesheets/mobile/openid_connect_error_page.scss b/app/assets/stylesheets/mobile/openid_connect_error_page.scss new file mode 100644 index 000000000..c87efeb4e --- /dev/null +++ b/app/assets/stylesheets/mobile/openid_connect_error_page.scss @@ -0,0 +1,9 @@ +.landing { margin: -56px -20px 10px; } + +.api-error { + background-color: $light-grey; + box-shadow: $card-shadow; + margin-top: 20px; + + h4 { text-align: center; } +} diff --git a/app/controllers/api/openid_connect/authorizations_controller.rb b/app/controllers/api/openid_connect/authorizations_controller.rb index 7acddcfaf..5dae076e5 100644 --- a/app/controllers/api/openid_connect/authorizations_controller.rb +++ b/app/controllers/api/openid_connect/authorizations_controller.rb @@ -177,7 +177,7 @@ module Api if params[:client_id] && params[:redirect_uri] handle_params_error_when_client_id_and_redirect_uri_exists(error, error_description) else - render_error error_description + render_error I18n.t("api.openid_connect.error_page.could_not_authorize"), error_description end end @@ -186,7 +186,8 @@ module Api if app && app.redirect_uris.include?(params[:redirect_uri]) redirect_prompt_error_display(error, error_description) else - render_error "Invalid client id or redirect uri" + render_error I18n.t("api.openid_connect.error_page.could_not_authorize"), + "Invalid client id or redirect uri" end end @@ -239,10 +240,14 @@ module Api redirect_to new_api_openid_connect_authorization_path(params) end - def render_error(error_description) + def render_error(error_description, detailed_error=nil) @error_description = error_description - render "api/openid_connect/error/error", - layout: request.format == :mobile ? "application" : "with_header_with_footer" + @detailed_error = detailed_error + if request.format == :mobile + render "api/openid_connect/error/error.mobile", layout: "application.mobile" + else + render "api/openid_connect/error/error", layout: "with_header_with_footer" + end end end end diff --git a/app/views/api/openid_connect/error/_error.html.haml b/app/views/api/openid_connect/error/_error.html.haml index 78ff3f9f4..de8d782b0 100644 --- a/app/views/api/openid_connect/error/_error.html.haml +++ b/app/views/api/openid_connect/error/_error.html.haml @@ -4,4 +4,8 @@ %h4 %b= t("api.openid_connect.error_page.title") %div{id: "openid_connect_error_description"} - = @error_description + %p= @error_description + - unless @detailed_error.nil? + %p= t("api.openid_connect.error_page.contact_developer") + %pre= @detailed_error + diff --git a/app/views/api/openid_connect/error/error.mobile.haml b/app/views/api/openid_connect/error/error.mobile.haml index a9b15dbd0..dcfd1f5f8 100644 --- a/app/views/api/openid_connect/error/error.mobile.haml +++ b/app/views/api/openid_connect/error/error.mobile.haml @@ -1 +1,8 @@ +.landing + %h1.session + = pod_name + = render partial: "api/openid_connect/error/error" + +%footer + = link_to t("layouts.application.toggle"), toggle_mobile_path diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 349c027df..09b20142c 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -919,6 +919,9 @@ en: description: "This allows the application to send new posts, write conversations, and send reactions" error_page: title: "Oh! Something went wrong :(" + contact_developer: "You should contact the developer of the application and include the following detailed message error:" + login_required: "You must first login before authorize this application" + could_not_authorize: "The application could not be authorized" people: zero: "No people"