-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from martinjonsson01/120-user-logout
120 user logout
- Loading branch information
Showing
15 changed files
with
111 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@using Blazorise.Extensions | ||
@using System.Net.Http.Headers | ||
@inject IJSRuntime Js | ||
@inject ISessionService Session | ||
@inherits AuthenticatedView | ||
|
||
@if (Session.IsAuthenticated) | ||
{ | ||
<div class="d-flex flex-row align-items-center"> | ||
<p id="logged-in" class="text-center m-0"> | ||
Inloggad som: @Session.Username | ||
</p> | ||
<button id="logout-button" class="btn btn-link" @onclick="@(async () => await Session.EndAsync())">Logga ut</button> | ||
</div> | ||
} | ||
else | ||
{ | ||
<button id="login-button" | ||
class="btn btn-primary" | ||
data-bs-toggle="modal" | ||
data-bs-target="#log-in" | ||
@onclick="FocusUsernameField"> | ||
Logga in | ||
</button> | ||
} | ||
@code { | ||
|
||
private async Task FocusUsernameField() | ||
{ | ||
// Focuses the username text input element. | ||
await Js.InvokeVoidAsync("focusElement", "#username"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#logged-in { | ||
color: var(--prodigo-white); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,3 @@ | |
.navbar { | ||
padding: 1rem 0; | ||
} | ||
|
||
#logged-in { | ||
color: var(--prodigo-white); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Threading.Tasks; | ||
|
||
using Application.Users; | ||
|
||
using Client.Shared; | ||
|
||
using Microsoft.AspNetCore.Components.Web; | ||
|
||
namespace Client.Tests.Shared.Login; | ||
|
||
public class LoginTests : UITestFixture | ||
{ | ||
[Fact] | ||
public async Task PressLogout_EndsSession_WhenUserWasAuthenticated() | ||
{ | ||
// Arrange | ||
MockSession.Setup(session => session.IsAuthenticated).Returns(true); | ||
await SessionStorage.SetItemAsync("user", new AuthenticateResponse(LoggedInUser, FakeToken)); | ||
|
||
IRenderedComponent<NavMenu> cut = Context.RenderComponent<NavMenu>(); | ||
|
||
// Act | ||
await cut.Find("#logout-button").ClickAsync(new MouseEventArgs()); | ||
|
||
// Assert | ||
MockSession.Verify(session => session.EndAsync(), Times.Once); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters