Skip to content

Commit 2ad686e

Browse files
committed
Fix B2C edit-profile and reset-password links
1 parent 67e4a47 commit 2ad686e

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

.env.sample.b2c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ CLIENT_ID=<client id>
44
CLIENT_SECRET=<client secret>
55
# Expects the display name such as "contoso"
66
TENANT_NAME=<tenant name>
7-
SIGNUPSIGNIN_USER_FLOW=B2C_1_profile_editing
8-
EDITPROFILE_USER_FLOW=B2C_1_reset_password
9-
RESETPASSWORD_USER_FLOW=B2C_1_signupsignin1
7+
SIGNUPSIGNIN_USER_FLOW=B2C_1_signupsignin1
8+
EDITPROFILE_USER_FLOW=B2C_1_profile_editing
9+
RESETPASSWORD_USER_FLOW=B2C_1_reset_password

app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from werkzeug.middleware.proxy_fix import ProxyFix
2020
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
2121

22+
app.jinja_env.globals.update(Auth=identity.web.Auth) # Useful in template for B2C
2223
auth = identity.web.Auth(
2324
session=session,
2425
authority=app.config["AUTHORITY"],

templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h2>Welcome {{ user.get("name") }}!</h2>
1414
{% endif %}
1515

1616
{% if config.get("B2C_PROFILE_AUTHORITY") %}
17-
<li><a href='{{config.get("B2C_PROFILE_AUTHORITY")}}?client_id={{config.get("CLIENT_ID")}}'>Edit Profile</a></li>
17+
<li><a href='{{Auth(session={}, authority=config["B2C_PROFILE_AUTHORITY"], client_id=config["CLIENT_ID"]).log_in(redirect_uri=url_for("auth_response", _external=True))["auth_uri"]}}'>Edit Profile</a></li>
1818
{% endif %}
1919

2020
<li><a href="/logout">Logout</a></li>

templates/login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1>Microsoft Identity Python Web App</h1>
2020
{% endif %}
2121

2222
{% if config.get("B2C_RESET_PASSWORD_AUTHORITY") %}
23-
<a href="{{config.get('B2C_RESET_PASSWORD_AUTHORITY')}}?client_id={{config.get('CLIENT_ID')}}">Reset Password</a>
23+
<a href='{{Auth(session={}, authority=config["B2C_RESET_PASSWORD_AUTHORITY"], client_id=config["CLIENT_ID"]).log_in(redirect_uri=url_for("auth_response", _external=True))["auth_uri"]}}'>Reset Password</a>
2424
{% endif %}
2525

2626
<hr>

0 commit comments

Comments
 (0)