Closed VanRhapsody closed 1 month ago
We're gonna use JWT Tokens stored in cookies to check if you're authorized. It's kinda like how PHP does it, but Blazor makes it easier. Check out this snippet:
<AuthorizeView>
<Authorized>
<p>Hello, @context.User.Identity?.Name!</p>
<p><button @onclick="SecureMethod">Authorized Only Button</button></p>
</Authorized>
<NotAuthorized>
<p>You're not authorized.</p>
</NotAuthorized>
</AuthorizeView>
The login component is a good idea and should be used with MudBlazor Popover.
For more details, check out the documentation here.
Also, this does not contain any logout functionality and should be covered in another issue regarding both backend and frontend.
Proposal The Navbar component should have an if statement which checks whether she session variable for being logged in is True and based on that will display either the user's profile picture and username (could possibly be a component too) or an option to sign in
Detail The if statement depends on how we're going to check whether the user is logged in. This approach is mainly used in PHP