1212using WebExpress . WebCore . WebEndpoint ;
1313using WebExpress . WebCore . WebIdentity . Model ;
1414using WebExpress . WebCore . WebMessage ;
15+ using WebExpress . WebCore . WebPage ;
1516using WebExpress . WebCore . WebPlugin ;
1617using WebExpress . WebCore . WebSession . Model ;
1718
@@ -385,7 +386,7 @@ private void OnAddApplication(object sender, IApplicationContext e)
385386 /// An object that represents the response to the login dialog, including authentication results
386387 /// and any relevant status information.
387388 /// </returns>
388- public IResponse CreateAuthenticationPrompt ( IRequest request , IEndpointContext initiator , IIdentity identity = null )
389+ public IResponse CreateAuthenticationPrompt ( IRequest request , IPageContext initiator , IIdentity identity = null )
389390 {
390391 if ( _identityProviders . TryGetValue ( initiator ? . ApplicationContext , out var list ) )
391392 {
@@ -415,7 +416,7 @@ public IResponse CreateAuthenticationPrompt(IRequest request, IEndpointContext i
415416 /// A response representing the forbidden page if a registered identity provider can handle the
416417 /// forbidden scenario; otherwise, <c>null</c>.
417418 /// </returns>
418- public IResponse CreateForbiddenResponse ( IRequest request , IEndpointContext initiator , IIdentity identity )
419+ public IResponse CreateForbiddenResponse ( IRequest request , IPageContext initiator , IIdentity identity )
419420 {
420421 if ( _identityProviders . TryGetValue ( initiator ? . ApplicationContext , out var list ) )
421422 {
@@ -434,48 +435,29 @@ public IResponse CreateForbiddenResponse(IRequest request, IEndpointContext init
434435 return null ;
435436 }
436437
437- /// <summary>
438- /// Attempts to authenticate the specified request within the given application context.
439- /// </summary>
440- /// <param name="request">The request to be authenticated. Must not be null.</param>
441- /// <param name="applicationContext">The application context in which the authentication is performed. Must not be null.</param>
442- /// <returns>An identity representing the authenticated user if authentication is successful; otherwise, null.</returns>
443- public IIdentity Authenticate ( IRequest request , IApplicationContext applicationContext )
444- {
445- if ( _identityProviders . TryGetValue ( applicationContext , out var list ) )
446- {
447- foreach ( var provider in list )
448- {
449- var identity = provider . Authenticate ( request ) ;
450-
451- if ( identity is not null )
452- {
453- return identity ;
454- }
455- }
456- }
457-
458- return null ;
459- }
460-
461438 /// <summary>
462439 /// Login an identity.
463440 /// </summary>
464- /// <param name="request">The request.</param>
465441 /// <param name="identity">The identity.</param>
466- /// <returns>True if successful, false otherwise.</returns>
467- public bool Login ( IRequest request , IIdentity identity )
442+ /// <param name="request">The request.</param>
443+ /// <returns>The session of the logged-in identity, or null if the login process failed.</returns>
444+ public Session Login ( IIdentity identity , IRequest request )
468445 {
469446 if ( identity is null )
470447 {
471- return false ;
448+ return null ;
472449 }
473450
474451 var session = _componentHub . SessionManager . GetSession ( request ) ;
475452 var authentification = session . GetOrCreateProperty < SessionPropertyAuthentification > ( identity ) ;
476453
477454 // verify that the identity was correctly bound to the session
478- return authentification . Identity == identity ;
455+ if ( authentification . Identity != identity )
456+ {
457+ return null ;
458+ }
459+
460+ return session ;
479461 }
480462
481463 /// <summary>
@@ -484,15 +466,6 @@ public bool Login(IRequest request, IIdentity identity)
484466 /// <param name="request">The request.</param>
485467 public void Logout ( IRequest request )
486468 {
487- // notify all registered identity providers so they can clear their own state
488- foreach ( var list in _identityProviders . Values )
489- {
490- foreach ( var provider in list )
491- {
492- provider . Logout ( request ) ;
493- }
494- }
495-
496469 var session = _componentHub . SessionManager . GetSession ( request ) ;
497470 session . RemoveProperty < SessionPropertyAuthentification > ( ) ;
498471 }
0 commit comments