File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -29,15 +29,18 @@ def login():
2929
3030@app .route (app_config .REDIRECT_PATH ) # Its absolute URL must match your app's redirect_uri set in AAD
3131def authorized ():
32- if request .args .get ('state' ) == session .get ("state" ):
32+ if request .args .get ('state' ) != session .get ("state" ):
33+ return redirect (url_for ("index" )) # No-OP. Goes back to Index page
34+ if "error" in request .args : # Authentication/Authorization failure
35+ return render_template ("auth_error.html" , result = request .args )
36+ if request .args .get ('code' ):
3337 cache = _load_cache ()
3438 result = _build_msal_app (cache = cache ).acquire_token_by_authorization_code (
3539 request .args ['code' ],
3640 scopes = app_config .SCOPE , # Misspelled scope would cause an HTTP 400 error here
3741 redirect_uri = url_for ("authorized" , _external = True ))
3842 if "error" in result :
39- return "Login failure: %s, %s" % (
40- result ["error" ], result .get ("error_description" ))
43+ return render_template ("auth_error.html" , result = result )
4144 session ["user" ] = result .get ("id_token_claims" )
4245 _save_cache (cache )
4346 return redirect (url_for ("index" ))
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ </ head >
6+ < body >
7+ < h2 > Login Failure</ h2 >
8+ < dl >
9+ < dt > {{ result.get("error") }}</ dt >
10+ < dd > {{ result.get("error_description") }}</ dd >
11+ </ dl >
12+ < hr >
13+ < a href ="{{ url_for('index') }} "> Homepage</ a >
14+ </ body >
15+ </ html >
16+
You can’t perform that action at this time.
0 commit comments