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 @@ + + +
+ + +