66const express = require ( 'express' ) ;
77const router = express . Router ( ) ;
88const authProvider = require ( '../auth/AuthProvider' ) ;
9+ const temp = require ( "@azure/msal-node" )
10+
911var { fetch } = require ( "../fetch" ) ;
1012const { GRAPH_ME_ENDPOINT ,
1113 mfaProtectedResourceScope } = require ( '../authConfig' ) ;
@@ -29,22 +31,40 @@ router.get('/id',
2931router . get (
3032 '/updateProfile' ,
3133 isAuthenticated , // check if user is authenticated
32- authProvider . getToken ( [ "User.ReadWrite" ] ) , // check for mfa
34+ authProvider . getToken ( [ "User.ReadWrite" ] ) ,
3335 async function ( req , res , next ) {
36+ let doesRequiredMFA = authProvider . doesRequireMFA ( req . session . accessToken ) ;
3437 const graphResponse = await fetch (
3538 GRAPH_ME_ENDPOINT ,
3639 req . session . accessToken
3740 ) ;
3841 res . render ( "updateProfile" , {
3942 profile : graphResponse ,
43+ doesRequiredMFA : doesRequiredMFA
4044 } ) ;
4145 }
4246) ;
4347
48+ router . get (
49+ '/gatedUpdateProfile' ,
50+ isAuthenticated , // check if user is authenticated
51+ authProvider . getToken ( [ "User.ReadWrite" , mfaProtectedResourceScope ] ,
52+ "http://localhost:3000/users/gatedUpdateProfile" ) , // check for mfa
53+ async function ( req , res , next ) {
54+ const graphResponse = await fetch (
55+ GRAPH_ME_ENDPOINT ,
56+ req . session . accessToken
57+ ) ;
58+ res . render ( "updateProfile" , {
59+ profile : graphResponse ,
60+ doesRequiredMFA : false
61+ } ) ;
62+ }
63+ ) ;
64+
4465router . post (
4566 '/update' ,
4667 isAuthenticated , // check if user is authenticated
47- authProvider . getToken ( [ "User.ReadWrite" , mfaProtectedResourceScope ] ) , // check for mfa
4868 async function ( req , res , next ) {
4969 try {
5070 if ( ! ! req . body ) {
0 commit comments