mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
(fix:oauth) handle access denied
This commit is contained in:
@@ -276,6 +276,10 @@ class ConnectorsCallback(Resource):
|
|||||||
error = request.args.get('error')
|
error = request.args.get('error')
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
|
if error == "access_denied":
|
||||||
|
return redirect(f"/api/connectors/callback-status?status=cancelled&message=Authentication+was+cancelled.+You+can+try+again+if+you'd+like+to+connect+your+account.&provider={provider}")
|
||||||
|
else:
|
||||||
|
current_app.logger.warning(f"OAuth error in callback: {error}")
|
||||||
return redirect(f"/api/connectors/callback-status?status=error&message=Authentication+failed.+Please+try+again+and+make+sure+to+grant+all+requested+permissions.&provider={provider}")
|
return redirect(f"/api/connectors/callback-status?status=error&message=Authentication+failed.+Please+try+again+and+make+sure+to+grant+all+requested+permissions.&provider={provider}")
|
||||||
|
|
||||||
if not authorization_code:
|
if not authorization_code:
|
||||||
@@ -644,6 +648,7 @@ class ConnectorCallbackStatus(Resource):
|
|||||||
.container {{ max-width: 600px; margin: 0 auto; }}
|
.container {{ max-width: 600px; margin: 0 auto; }}
|
||||||
.success {{ color: #4CAF50; }}
|
.success {{ color: #4CAF50; }}
|
||||||
.error {{ color: #F44336; }}
|
.error {{ color: #F44336; }}
|
||||||
|
.cancelled {{ color: #FF9800; }}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
window.onload = function() {{
|
window.onload = function() {{
|
||||||
@@ -658,6 +663,8 @@ class ConnectorCallbackStatus(Resource):
|
|||||||
user_email: userEmail
|
user_email: userEmail
|
||||||
}}, '*');
|
}}, '*');
|
||||||
|
|
||||||
|
setTimeout(() => window.close(), 3000);
|
||||||
|
}} else if (status === "cancelled" || status === "error") {{
|
||||||
setTimeout(() => window.close(), 3000);
|
setTimeout(() => window.close(), 3000);
|
||||||
}}
|
}}
|
||||||
}};
|
}};
|
||||||
@@ -670,7 +677,7 @@ class ConnectorCallbackStatus(Resource):
|
|||||||
<p>{message}</p>
|
<p>{message}</p>
|
||||||
{f'<p>Connected as: {user_email}</p>' if status == 'success' else ''}
|
{f'<p>Connected as: {user_email}</p>' if status == 'success' else ''}
|
||||||
</div>
|
</div>
|
||||||
<p><small>You can close this window. {f"Your {provider.replace('_', ' ').title()} is now connected and ready to use." if status == 'success' else ''}</small></p>
|
<p><small>You can close this window. {f"Your {provider.replace('_', ' ').title()} is now connected and ready to use." if status == 'success' else "Feel free to close this window."}</small></p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user