TheDarkun / Elevators

Fullstack .NET Project for SOČ
0 stars 0 forks source link

Variable content in Navbar depending on the user being logged in #10

Closed VanRhapsody closed 1 month ago

VanRhapsody commented 7 months ago

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

TheDarkun commented 7 months 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.

image

For more details, check out the documentation here.

TheDarkun commented 7 months ago

Also, this does not contain any logout functionality and should be covered in another issue regarding both backend and frontend.