From e94271e45a0f9eff21f2e6e9391d2d2021293903 Mon Sep 17 00:00:00 2001 From: khushal Date: Fri, 29 Nov 2024 14:34:35 +0530 Subject: [PATCH] (20241129) HTML views adjusted. --- api/blueprints/mail/oauth_callback.py | 8 +- views/mail/oauth/oauth_cancelled_v2.html | 114 +++++++++++++++++++++++ views/mail/oauth/oauth_failure_v2.html | 114 +++++++++++++++++++++++ views/mail/oauth/oauth_success_v2.html | 113 ++++++++++++++++++++++ 4 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 views/mail/oauth/oauth_cancelled_v2.html create mode 100644 views/mail/oauth/oauth_failure_v2.html create mode 100644 views/mail/oauth/oauth_success_v2.html diff --git a/api/blueprints/mail/oauth_callback.py b/api/blueprints/mail/oauth_callback.py index 1d8f23b..f78279c 100644 --- a/api/blueprints/mail/oauth_callback.py +++ b/api/blueprints/mail/oauth_callback.py @@ -150,6 +150,12 @@ async def mail_callback( if mail_client == "gmail": + # In case the user cancelled halfway through (on Google's screen): + if inbound_data.get("error") == "access_denied": return await render_template( + "/mail/oauth/oauth_cancelled_v2.html", + mail_client = mail_client.title() + ) + # Generate the tokens from the callback: tokens = await current_app.gmail_client.get_authorization_tokens( redirect_url = request.url, @@ -188,7 +194,7 @@ async def mail_callback( # Return an HTML response: return await render_template( - "/mail/oauth/oauth_success.html" if tokens_saved else "/mail/oauth/oauth_failure.html", + "/mail/oauth/oauth_success_v2.html" if tokens_saved else "/mail/oauth/oauth_failure_v2.html", mail_client = mail_client.title() ) diff --git a/views/mail/oauth/oauth_cancelled_v2.html b/views/mail/oauth/oauth_cancelled_v2.html new file mode 100644 index 0000000..368e9a2 --- /dev/null +++ b/views/mail/oauth/oauth_cancelled_v2.html @@ -0,0 +1,114 @@ + + + + + + Authorization Cancelled + + + + + + +
+
!
+

Authorization Cancelled

+

It seems that the authorization for your {{ mail_client }} account was cancelled unexpectedly. + Please feel free to try again whenever you feel like it. You can close this tab at any time.

+ + + +
+ + + + + diff --git a/views/mail/oauth/oauth_failure_v2.html b/views/mail/oauth/oauth_failure_v2.html new file mode 100644 index 0000000..4443581 --- /dev/null +++ b/views/mail/oauth/oauth_failure_v2.html @@ -0,0 +1,114 @@ + + + + + + Authorization Failed + + + + + + +
+
+

Authorization Failed

+

Something went wrong in getting authorization from your {{ mail_client }} account. + Please feel free to try the same steps again. You can close this tab at any time.

+ + + +
+ + + + + diff --git a/views/mail/oauth/oauth_success_v2.html b/views/mail/oauth/oauth_success_v2.html new file mode 100644 index 0000000..929f50c --- /dev/null +++ b/views/mail/oauth/oauth_success_v2.html @@ -0,0 +1,113 @@ + + + + + + Authorization Successful + + + + + + +
+
+

Authorization Successful

+

We have received authorization from your {{ mail_client }} account. You can close this tab at any time.

+ + + +
+ + + + +