Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 58ed697

Browse files
author
derisen
committed
edit profile button
1 parent 1f13e45 commit 58ed697

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

JavaScriptSPA/authPopup.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,18 @@ function passTokenToApi() {
6464
console.log(err);
6565
}
6666
});
67+
}
68+
69+
function editProfile() {
70+
71+
const request = {
72+
scopes: ["https://fabrikamb2c.onmicrosoft.com/helloapi/demo.read"],
73+
authority: b2cPolicies.authorities.editProfile.authority
74+
}
75+
76+
myMSALObj.loginPopup(request)
77+
.then(tokenResponse => {
78+
console.log("access_token acquired at: " + new Date().toString());
79+
console.log(tokenResponse);
80+
});
6781
}

JavaScriptSPA/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ <h5 class="card-header text-center">Getting an access token with Azure AD B2C an
3636
<h5 id="label" class="card-title">Sign-in with Microsoft Azure AD B2C</h5>
3737
<pre id="response" class="card-text"></pre>
3838
<button type="button" id="callApiButton" class="btn btn-primary d-none" onclick="passTokenToApi()">Call API</button>
39+
<button type="button" id="editProfileButton" class="btn btn-primary d-none" onclick="editProfile()">Edit Profile</button>
3940
</div>
4041
</div>
4142

JavaScriptSPA/policies.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ const b2cPolicies = {
1414
forgotPassword: {
1515
authority: "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/b2c_1_reset",
1616
},
17+
editProfile: {
18+
authority: "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/b2c_1_edit_profile"
19+
}
1720
},
1821
}

JavaScriptSPA/ui.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const signInButton = document.getElementById('signIn');
33
const signOutButton = document.getElementById('signOut');
44
const callWebApiButton = document.getElementById('callApiButton');
5+
const editProfileButton = document.getElementById('editProfileButton');
56
const label = document.getElementById('label');
67
const response = document.getElementById("response");
78

@@ -17,8 +18,9 @@ function updateUI() {
1718
label.innerText = "Hello " + userName;
1819

1920
// add the callWebApi button
20-
callWebApiButton.classList.add('d-none');
21-
callWebApiButton.setAttribute('class', 'btn btn-primary');
21+
callWebApiButton.classList.remove('d-none');
22+
// add the callWebApi button
23+
editProfileButton.classList.remove('d-none');
2224
}
2325

2426
// debug helper

0 commit comments

Comments
 (0)