From 72ceeda8727010aed926ea72cae9b56388ab639e Mon Sep 17 00:00:00 2001 From: Kristian Feldsam Date: Fri, 22 Oct 2021 14:37:26 +0200 Subject: [PATCH] [Web] oauth authorize - added missing twig templating --- data/web/oauth/authorize.php | 107 +++++++++--------------- data/web/templates/oauth/authorize.twig | 27 ++++++ 2 files changed, 65 insertions(+), 69 deletions(-) create mode 100644 data/web/templates/oauth/authorize.twig diff --git a/data/web/oauth/authorize.php b/data/web/oauth/authorize.php index 48e99b0c..1fdcd033 100644 --- a/data/web/oauth/authorize.php +++ b/data/web/oauth/authorize.php @@ -1,69 +1,38 @@ -validateAuthorizeRequest($request, $response)) { - $response->send(); - exit(); -} - -if (!isset($_POST['authorized'])): -require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php'; - -?> -
-
-
-
- -

- -

:

-
-
-
-
-
-
-
- - - -
-
-
- -
-
-
-handleAuthorizeRequest($request, $response, $is_authorized, $_SESSION['mailcow_cc_username']); -if ($is_authorized) { - unset($_SESSION['oauth2_request']); - if ($GLOBALS['OAUTH2_FORGET_SESSION_AFTER_LOGIN'] === true) { - session_unset(); - session_destroy(); - } - header('Location: ' . $response->getHttpHeader('Location')); - exit; -} +validateAuthorizeRequest($request, $response)) { + $response->send(); + exit; +} + +if (!isset($_POST['authorized'])) { + require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php'; + + $template = 'oauth/authorize.twig'; + $template_data = []; + + require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; + exit; +} + +// print the authorization code if the user has authorized your client +$is_authorized = ($_POST['authorized'] == '1'); +$oauth2_server->handleAuthorizeRequest($request, $response, $is_authorized, $_SESSION['mailcow_cc_username']); +if ($is_authorized) { + unset($_SESSION['oauth2_request']); + if ($GLOBALS['OAUTH2_FORGET_SESSION_AFTER_LOGIN'] === true) { + session_unset(); + session_destroy(); + } + header('Location: ' . $response->getHttpHeader('Location')); + exit; +} diff --git a/data/web/templates/oauth/authorize.twig b/data/web/templates/oauth/authorize.twig new file mode 100644 index 00000000..289eab34 --- /dev/null +++ b/data/web/templates/oauth/authorize.twig @@ -0,0 +1,27 @@ +{% extends 'base.twig' %} + +{% block content %} +
+
{{ lang.oauth2.authorize_app }}
+
+ {% if mailcow_cc_role == 'user' %} +

{{ lang.oauth2.scope_ask_permission }}:

+
+
{{ lang.oauth2.profile }}
+
{{ lang.oauth2.profile_desc }}
+
+
+
+
+ + {{ lang.oauth2.deny }} + +
+
+
+ {% else %} +

{{ lang.oauth2.access_denied }}

+ {% endif %} +
+
+{% endblock %}