From 3889bf0766456fd579a5e6fafc9bc65f6f98fcc9 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Sun, 21 Jan 2024 16:35:53 +0000 Subject: [PATCH] Improve authorize page. --- etc/pages.json | 4 ++-- src/pages/p_authorize.php | 35 ++++++++++++++++++++++------------- stylesheets/style.css | 2 +- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/etc/pages.json b/etc/pages.json index 09bf6ba7a2..3b4b4c381e 100644 --- a/etc/pages.json +++ b/etc/pages.json @@ -213,12 +213,12 @@ { "name": "authorize", "print_function": "*Authorize_Page::go", "allow_disabled": true }, [ "authorize/form/title", 1, "*Authorize_Page::print_form_title" ], - [ "authorize/form/description", 10, "*Authorize_Page::print_form_description" ], [ "authorize/form/active", 15, "*Authorize_Page::print_form_active" ], [ "authorize/form/email", 20, "signin/form/email" ], [ "authorize/form/password", 30, "signin/form/password" ], [ "authorize/form/actions", 100, "*Authorize_Page::print_form_actions" ], - [ "authorize/form/oauth", 1000, "Signin_Page::print_signin_form_oauth" ], + [ "authorize/form/oauth", 1000, "*Signin_Page::print_signin_form_oauth" ], + [ "authorize/form/annotation", 2000, "*Authorize_Page::print_form_annotation" ], { "name": "api", "print_function": "API_Page::go", "allow_disabled": true }, diff --git a/src/pages/p_authorize.php b/src/pages/p_authorize.php index c509a7f19f..06d0c9d555 100644 --- a/src/pages/p_authorize.php +++ b/src/pages/p_authorize.php @@ -11,6 +11,8 @@ class OAuthClient { public $client_id; /** @var string */ public $client_secret; + /** @var ?string */ + public $client_uri; /** @var list */ public $redirect_uri = []; @@ -27,6 +29,7 @@ static function make($x) { $oac->title = $x->title ?? null; $oac->client_id = $x->client_id ?? null; $oac->client_secret = $x->client_secret ?? null; + $oac->client_uri = $x->client_uri ?? null; if (isset($x->redirect_uri)) { if (is_string($x->redirect_uri)) { $oac->redirect_uri[] = $x->redirect_uri; @@ -63,6 +66,8 @@ class Authorize_Page { public $qreq; /** @var ComponentSet */ public $cs; + /** @var OAuthClient */ + public $client; /** @var array */ private $clients = []; /** @var TokenInfo */ @@ -147,7 +152,8 @@ private function handle_request(OAuthClient $client) { ->change_data("redirect_uri", $this->qreq->redirect_uri); $this->token->create(); - $this->qreq->print_header("Sign in", "authorize", ["action_bar" => "", "hide_title" => true, "body_class" => "body-signin"]); + $this->client = $client; + $this->qreq->print_header("Sign in", "authorize", ["action_bar" => "", "hide_header" => true, "body_class" => "body-signin"]); Signin_Page::print_form_start_for($this->qreq, "=signin"); $nav = $this->qreq->navigation(); echo Ht::hidden("redirect", "authorize{$nav->php_suffix}?code=" . urlencode($this->token->salt) . "&authconfirm=1"); @@ -158,11 +164,17 @@ private function handle_request(OAuthClient $client) { } function print_form_title() { - echo '

Sign in

'; + echo '

Choose an account

'; + $clt = htmlspecialchars($this->client->title ?? $this->client->name); + if ($this->client->client_uri) { + $clt = Ht::link($clt, htmlspecialchars($this->client->client_uri)); + } + echo '
to continue to ', $clt, '
'; } - function print_form_description() { - + function print_form_annotation() { + $clt = htmlspecialchars($this->client->title ?? $this->client->name); + echo '

If you continue, HotCRP.com will share your name, email address, affiliation, and other profile information with ', $clt, '.

'; } function print_form_active() { @@ -173,10 +185,10 @@ function print_form_active() { continue; } $url = $nav->base_absolute() . "u/{$i}/authorize{$nav->php_suffix}?code=" . urlencode($this->token->salt) . "&authconfirm=1"; - $buttons[] = Ht::button("Sign in as " . htmlspecialchars($email), ["type" => "submit", "formaction" => $url, "formmethod" => "post", "class" => "mt-2 w-100 flex-grow-1"]); + $buttons[] = Ht::button("Sign in as " . htmlspecialchars($email), ["type" => "submit", "formaction" => $url, "formmethod" => "post", "class" => "mt-2 w-100 flex-grow-1 btn-primary"]); } if (!empty($buttons)) { - echo '
', join("", $buttons), '
'; + echo '
', join("", $buttons), '
'; } } @@ -184,12 +196,9 @@ function print_form_actions() { if (($lt = $this->conf->login_type()) === "none" || $lt === "oauth") { return; } - echo ''; + echo '
', + Ht::submit("", "Sign in", ["id" => "k-signin", "class" => "btn-success w-100 flex-grow-1", "tabindex" => 1]), + '
'; } private function handle_authconfirm() { @@ -264,7 +273,7 @@ private function print_error_exit($m) { if (http_response_code() === 200) { http_response_code(400); } - $this->qreq->print_header("Sign in", "authorize", ["action_bar" => "", "body_class" => "body-error"]); + $this->qreq->print_header("Sign in", "authorize", ["action_bar" => "", "hide_header" => true, "body_class" => "body-error"]); $this->conf->error_msg($m); $this->qreq->print_footer(); exit; diff --git a/stylesheets/style.css b/stylesheets/style.css index bc036944e7..5d2fca687e 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -1295,7 +1295,7 @@ strong.overdue { background: var(--brand-bg); margin-left: auto; margin-right: auto; - max-width: 600px; + max-width: 500px; width: fit-content; } .signingrp.homegrp {