Skip to content

Commit

Permalink
Add ResetPassword behavior, and refactor based on latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
rayluo committed Nov 7, 2019
1 parent e2a819f commit c50ce90
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
8 changes: 0 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ def logout():
app_config.AUTHORITY + "/oauth2/v2.0/logout" +
"?post_logout_redirect_uri=" + url_for("index", _external=True))

# This page is only used in B2C scenario
@app.route("/edit_profile")
def edit_profile():
app = _build_msal_app(authority=app_config.B2C_PROFILE_AUTHORITY)
return redirect(app.get_authorization_request_url([],
state=str(uuid.uuid4()),
redirect_uri=url_for("authorized", _external=True)))

@app.route("/graphcall")
def graphcall():
token = _get_token_from_cache(app_config.SCOPE)
Expand Down
3 changes: 3 additions & 0 deletions app_config_b2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
b2c_tenant = "fabrikamb2c"
signupsignin_user_flow = "b2c_1_signupsignin1"
editprofile_user_flow = "b2c_1_profileediting1"
resetpassword_user_flow = "b2c_1_passwordreset1"
authority_template = "https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{user_flow}"

CLIENT_SECRET = "Enter_the_Client_Secret_Here" # Our Quickstart uses this placeholder
Expand All @@ -17,6 +18,8 @@
tenant=b2c_tenant, user_flow=signupsignin_user_flow)
B2C_PROFILE_AUTHORITY = authority_template.format(
tenant=b2c_tenant, user_flow=editprofile_user_flow)
B2C_RESET_PASSWORD_AUTHORITY = authority_template.format(
tenant=b2c_tenant, user_flow=resetpassword_user_flow)

CLIENT_ID = "Enter_the_Application_Id_here"

Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2>Welcome {{ user.get("name") }}!</h2>
{% endif %}

{% if config.get("B2C_PROFILE_AUTHORITY") %}
<li><a href='/edit_profile'>Edit Profile</a></li>
<li><a href='{{_build_auth_url(authority=config["B2C_PROFILE_AUTHORITY"])}}'>Edit Profile</a></li>
{% endif %}

<li><a href="/logout">Logout</a></li>
Expand Down
4 changes: 4 additions & 0 deletions templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ <h1>Microsoft Identity Python Web App</h1>

<li><a href='{{ auth_url }}'>Sign In</a></li>

{% if config.get("B2C_RESET_PASSWORD_AUTHORITY") %}
<li><a href='{{_build_auth_url(authority=config["B2C_RESET_PASSWORD_AUTHORITY"])}}'>Reset Password</a></li>
{% endif %}

<hr>
<footer style="text-align: right">Powered by MSAL Python {{ version }}</footer>
</body>
Expand Down

0 comments on commit c50ce90

Please sign in to comment.