Back to Use Cases
Interactive Server
The following sequence diagrams illustrate the use cases for Blazor.Auth in a Blazor application that is currently using Interactive Server
render mode:
Sign-In
sequenceDiagram actor user as User participant page as Page box rgba(101, 63, 232, 0.5) Blazor.Auth participant userServiceServer as IUserService (Server) participant blazorClient as Client Machine participant blazorServer as Blazor Server end participant authService as IAuthenticationService (Server) user ->>+ page: Submit Sign-In Form page ->>+ userServiceServer: SignInAsync(signInPayload) note over page,userServiceServer: Resolve IUserService from DI<br/> and call it's `SignInAsync` method. userServiceServer ->>+ blazorClient: Remote JS Interop blazorClient ->>+ blazorServer: HTTP Request to <br/> Sign-In endpoint blazorServer ->>+ authService: SignInAsync(signInPayload) authService ->> authService: Your server-side sign-in logic authService -->>- blazorServer: AuthenticationResult blazorServer -->> blazorServer: Update authentication cookies blazorServer -->>- blazorClient: AuthenticationOperationInfo note over blazorClient,blazorServer: Updated cookies will be<br/>attached to the HTTP response. blazorClient -->>- userServiceServer: AuthenticationOperationInfo userServiceServer -->>- page: AuthenticationOperationInfo page -->>- user: Continue, <br/> e.g. redirect to home page, <br/> or other custom logic note over user,userServiceServer: Upon receiving AuthenticationOperationInfo from IUserService, <br/> do a page refresh in order to refresh the User's AuthenticationState<br/><br/> Example: NavigationManager.NavigateTo("/", true).
Sign-Out
sequenceDiagram actor user as User participant page as Page box rgba(101, 63, 232, 0.5) Blazor.Auth participant userServiceServer as IUserService (Server) participant blazorClient as Client Machine participant blazorServer as Blazor Server end user ->>+ page: Submit Sign-Out Form page ->>+ userServiceServer: SignOutAsync() note over page,userServiceServer: Resolve IUserService from DI<br/> and call it's `SignOutAsync` method. userServiceServer ->>+ blazorClient: Remote JS Interop blazorClient ->>+ blazorServer: HTTP Request to <br/> Sign-Out endpoint blazorServer -->> blazorServer: Clear authentication cookies blazorServer -->>- blazorClient: #32; note over blazorClient,blazorServer: Blazor.Auth will clear the user's <br/> authentication cookies <br/> by marking them as expired <br/> in the HTTP response. blazorClient -->>- userServiceServer: #32; userServiceServer -->>- page: #32; page -->>- user: Continue, <br/> e.g. redirect to home page, <br/> or other custom logic note over user,userServiceServer: Upon finishing method execution, <br/> do a page refresh in order to refresh the User's AuthenticationState<br/><br/> Example: NavigationManager.NavigateTo("/", true).
Sign-Up
sequenceDiagram actor user as User participant page as Page box rgba(101, 63, 232, 0.5) Blazor.Auth participant userServiceServer as IUserService (Server) participant blazorClient as Client Machine participant blazorServer as Blazor Server end participant authService as IAuthenticationService (Server) user ->>+ page: Submit Sign-Up Form page ->>+ userServiceServer: SignUpAsync(signUpPayload) note over page,userServiceServer: Resolve IUserService from DI<br/> and call it's `SignUpAsync` method. userServiceServer ->>+ blazorClient: Remote JS Interop blazorClient ->>+ blazorServer: HTTP Request to <br/> Sign-Up endpoint blazorServer ->>+ authService: SignUpAsync(signUpPayload) authService ->> authService: Your server-side sign-up logic authService -->>- blazorServer: AuthenticationResult blazorServer -->> blazorServer: Update authentication cookies blazorServer -->>- blazorClient: AuthenticationOperationInfo note over blazorClient,blazorServer: Updated cookies will be<br/>attached to the HTTP response. blazorClient -->>- userServiceServer: AuthenticationOperationInfo userServiceServer -->>- page: AuthenticationOperationInfo page -->>- user: Continue, <br/> e.g. redirect to home page, <br/> or other custom logic note over user,userServiceServer: Upon receiving AuthenticationOperationInfo from IUserService, <br/> do a page refresh in order to refresh the User's AuthenticationState<br/><br/> Example: NavigationManager.NavigateTo("/", true).