File tree Expand file tree Collapse file tree 2 files changed +26
-12
lines changed
src/Components/WebAssembly/Authentication.Msal/src Expand file tree Collapse file tree 2 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ interface AuthorizeService {
47
47
48
48
interface AuthorizeServiceConfiguration extends Msal . Configuration {
49
49
defaultAccessTokenScopes : string [ ] ;
50
- additionalScopesToConsent : string [ ]
50
+ additionalScopesToConsent : string [ ] ;
51
+ loginMode : string ;
51
52
}
52
53
53
54
class MsalAuthorizeService implements AuthorizeService {
@@ -142,18 +143,26 @@ class MsalAuthorizeService implements AuthorizeService {
142
143
}
143
144
144
145
async signInCore ( request : Msal . AuthenticationParameters ) : Promise < Msal . AuthResponse | Msal . AuthError | undefined > {
145
- try {
146
- return await this . _msalApplication . loginPopup ( request ) ;
147
- } catch ( e ) {
148
- // If the user explicitly cancelled the pop-up, avoid performing a redirect.
149
- if ( this . isMsalError ( e ) && e . errorCode !== ClientAuthErrorMessage . userCancelledError . code ) {
150
- try {
151
- this . _msalApplication . loginRedirect ( request ) ;
152
- } catch ( e ) {
146
+ if ( this . _settings . loginMode . toLowerCase ( ) === "redirect" ) {
147
+ try {
148
+ this . _msalApplication . loginRedirect ( request ) ;
149
+ } catch ( e ) {
150
+ return e ;
151
+ }
152
+ } else {
153
+ try {
154
+ return await this . _msalApplication . loginPopup ( request ) ;
155
+ } catch ( e ) {
156
+ // If the user explicitly cancelled the pop-up, avoid performing a redirect.
157
+ if ( this . isMsalError ( e ) && e . errorCode !== ClientAuthErrorMessage . userCancelledError . code ) {
158
+ try {
159
+ this . _msalApplication . loginRedirect ( request ) ;
160
+ } catch ( e ) {
161
+ return e ;
162
+ }
163
+ } else {
153
164
return e ;
154
165
}
155
- } else {
156
- return e ;
157
166
}
158
167
}
159
168
}
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public class MsalProviderOptions
14
14
/// <summary>
15
15
/// Gets or sets the <see cref="MsalAuthenticationOptions"/> to use for authentication operations.
16
16
/// </summary>
17
- [ JsonPropertyName ( "auth" ) ]
17
+ [ JsonPropertyName ( "auth" ) ]
18
18
public MsalAuthenticationOptions Authentication { get ; set ; } = new MsalAuthenticationOptions
19
19
{
20
20
RedirectUri = "authentication/login-callback" ,
@@ -43,5 +43,10 @@ public class MsalProviderOptions
43
43
/// Use this parameter to request consent for scopes for other resources.
44
44
/// </remarks>
45
45
public IList < string > AdditionalScopesToConsent { get ; set ; } = new List < string > ( ) ;
46
+
47
+ /// <summary>
48
+ /// Gets or sets the login mode that is used when initiating the sign-in flow.
49
+ /// </summary>
50
+ public string LoginMode { get ; set ; } = "popup" ;
46
51
}
47
52
}
You can’t perform that action at this time.
0 commit comments