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