This repository has been archived by the owner. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +28
-16
lines changed
Expand file tree Collapse file tree 5 files changed +28
-16
lines changed Original file line number Diff line number Diff line change 11# CHANGELOG
22
3+ ## 08/31/2020
4+
5+ * Updated MSAL.js to 1.4.0
6+ * Added Profile Edit user-flow.
7+
38## 08/05/2020
49
510* Updated to MSAL.js to 1.3.2.
Original file line number Diff line number Diff line change @@ -67,15 +67,9 @@ function passTokenToApi() {
6767}
6868
6969function 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- } ) ;
70+ myMSALObj . loginPopup ( b2cPolicies . authorities . editProfile )
71+ . then ( tokenResponse => {
72+ console . log ( "access_token acquired at: " + new Date ( ) . toString ( ) ) ;
73+ console . log ( tokenResponse ) ;
74+ } ) ;
8175}
Original file line number Diff line number Diff line change @@ -26,9 +26,17 @@ function authRedirectCallBack(error, response) {
2626 // We need to reject id tokens that were not issued with the default sign-in policy.
2727 // "acr" claim in the token tells us what policy is used (NOTE: for new policies (v2.0), use "tfp" instead of "acr")
2828 // To learn more about b2c tokens, visit https://docs.microsoft.com/en-us/azure/active-directory-b2c/tokens-overview
29- if ( response . tokenType === "id_token" && response . idToken . claims [ 'acr' ] !== b2cPolicies . names . signUpSignIn ) {
29+ if ( response . tokenType === "id_token" && response . idToken . claims [ 'acr' ] === b2cPolicies . names . forgotPassword ) {
3030 myMSALObj . logout ( ) ;
3131 window . alert ( "Password has been reset successfully. \nPlease sign-in with your new password." ) ;
32+
33+ } else if ( response . tokenType === "id_token" && response . idToken . claims [ 'acr' ] === b2cPolicies . names . editProfile ) {
34+ window . alert ( "Profile has been updated successfully." ) ;
35+
36+ if ( myMSALObj . getAccount ( ) ) {
37+ updateUI ( ) ;
38+ }
39+
3240 } else if ( response . tokenType === "id_token" && response . idToken . claims [ 'acr' ] === b2cPolicies . names . signUpSignIn ) {
3341 console . log ( "id_token acquired at: " + new Date ( ) . toString ( ) ) ;
3442
@@ -101,3 +109,7 @@ function passTokenToApi() {
101109 }
102110 }
103111}
112+
113+ function editProfile ( ) {
114+ myMSALObj . loginRedirect ( b2cPolicies . authorities . editProfile ) ;
115+ }
Original file line number Diff line number Diff line change 2424 < nav class ="navbar navbar-expand-lg navbar-dark bg-primary ">
2525 < a class ="navbar-brand " href ="/ "> Azure AD B2C</ a >
2626 < div class ="btn-group ml-auto dropleft ">
27+ < button type ="button " id ="editProfileButton " class ="btn btn-secondary d-none " onclick ="editProfile() "> Edit Profile</ button >
2728 < button type ="button " id ="signIn " class ="btn btn-secondary " onclick ="signIn() "> Sign In</ button >
2829 < button type ="button " id ="signOut " class ="btn btn-success d-none " onclick ="logout() "> Sign Out</ button >
2930 </ div >
@@ -36,7 +37,6 @@ <h5 class="card-header text-center">Getting an access token with Azure AD B2C an
3637 < h5 id ="label " class ="card-title "> Sign-in with Microsoft Azure AD B2C</ h5 >
3738 < pre id ="response " class ="card-text "> </ pre >
3839 < 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 >
4040 </ div >
4141 </ div >
4242
@@ -52,8 +52,8 @@ <h5 id="label" class="card-title">Sign-in with Microsoft Azure AD B2C</h5>
5252 < script type ="text/javascript " src ="./ui.js "> </ script >
5353
5454 <!-- replace next line with authRedirect.js if you would like to use the redirect flow -->
55- <!-- < script type="text/javascript" src="./authRedirect.js"></script> -->
56- < script type ="text/javascript " src ="./authPopup.js "> </ script >
55+ < script type ="text/javascript " src ="./authRedirect.js "> </ script >
56+ <!-- < script type="text/javascript" src="./authPopup.js"></script> -- >
5757 < script type ="text/javascript " src ="./api.js "> </ script >
5858</ body >
5959</ html >
Original file line number Diff line number Diff line change 55const b2cPolicies = {
66 names : {
77 signUpSignIn : "b2c_1_susi" ,
8- forgotPassword : "b2c_1_reset"
8+ forgotPassword : "b2c_1_reset" ,
9+ editProfile : "b2c_1_edit_profile"
910 } ,
1011 authorities : {
1112 signUpSignIn : {
You can’t perform that action at this time.
0 commit comments