Add custom error page when prompt=none
This commit is contained in:
parent
10938404e9
commit
ebeafb7894
7 changed files with 30 additions and 4 deletions
|
|
@ -104,3 +104,6 @@
|
|||
|
||||
// settings
|
||||
@import 'user_applications';
|
||||
|
||||
// API
|
||||
@import "openid_connect_error_page";
|
||||
|
|
|
|||
7
app/assets/stylesheets/openid_connect_error_page.scss
Normal file
7
app/assets/stylesheets/openid_connect_error_page.scss
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
.api-error {
|
||||
margin-top: 20px;
|
||||
box-shadow: $card-shadow;
|
||||
background-color: $light-grey;
|
||||
|
||||
h4 { text-align: center; }
|
||||
}
|
||||
|
|
@ -110,8 +110,7 @@ module Api
|
|||
if auth
|
||||
process_authorization_consent("true")
|
||||
else
|
||||
handle_params_error("interaction_required",
|
||||
"The Authentication Request cannot be completed without end-user interaction")
|
||||
render_error "The Authentication Request cannot be completed without end-user interaction"
|
||||
end
|
||||
else
|
||||
handle_params_error("invalid_request",
|
||||
|
|
@ -219,12 +218,19 @@ module Api
|
|||
|
||||
def auth_user_unless_prompt_none!
|
||||
if params[:prompt] == "none" && !user_signed_in?
|
||||
handle_params_error("login_required",
|
||||
"User must already be logged in when 'prompt' is 'none'")
|
||||
render_error "User must be first logged in when `prompt` is `none`"
|
||||
# render json: {error: "login_required",
|
||||
# description: "User must be first logged in when `prompt` is `none`"}
|
||||
else
|
||||
authenticate_user!
|
||||
end
|
||||
end
|
||||
|
||||
def render_error(error_description)
|
||||
@error_description = error_description
|
||||
render "api/openid_connect/error/error",
|
||||
layout: request.format == :mobile ? "application" : "with_header_with_footer"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
6
app/views/api/openid_connect/error/_error.html.haml
Normal file
6
app/views/api/openid_connect/error/_error.html.haml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
.container-fluid
|
||||
.row
|
||||
.api-error.col-sm-6.col-sm-offset-3
|
||||
%h4
|
||||
%b= t("api.openid_connect.error_page.title")
|
||||
%div= @error_description
|
||||
1
app/views/api/openid_connect/error/error.html.haml
Normal file
1
app/views/api/openid_connect/error/error.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render partial: "api/openid_connect/error/error"
|
||||
1
app/views/api/openid_connect/error/error.mobile.haml
Normal file
1
app/views/api/openid_connect/error/error.mobile.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render partial: "api/openid_connect/error/error"
|
||||
|
|
@ -917,6 +917,8 @@ en:
|
|||
write:
|
||||
name: "send posts, conversations and reactions"
|
||||
description: "This allows the application to send new posts, write conversations, and send reactions"
|
||||
error_page:
|
||||
title: "Oh! Something went wrong :("
|
||||
|
||||
people:
|
||||
zero: "No people"
|
||||
|
|
|
|||
Loading…
Reference in a new issue