[frontend] Fix build warnings
This commit is contained in:
parent
98ac934897
commit
bc14abbacc
4 changed files with 26 additions and 17 deletions
|
@ -3,7 +3,7 @@ using Iceshrimp.Shared.Schemas;
|
||||||
|
|
||||||
namespace Iceshrimp.Frontend.Core.Schemas;
|
namespace Iceshrimp.Frontend.Core.Schemas;
|
||||||
|
|
||||||
public class StoredUser() : UserResponse
|
public class StoredUser : UserResponse
|
||||||
{
|
{
|
||||||
[JsonPropertyName("token")] public required string Token { get; set; }
|
[JsonPropertyName("token")] public required string Token { get; set; }
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
using Blazored.LocalStorage;
|
using Blazored.LocalStorage;
|
||||||
using Iceshrimp.Frontend.Core.Schemas;
|
using Iceshrimp.Frontend.Core.Schemas;
|
||||||
using Iceshrimp.Shared.Schemas;
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace Iceshrimp.Frontend.Core.Services;
|
namespace Iceshrimp.Frontend.Core.Services;
|
||||||
|
@ -50,7 +49,7 @@ internal class SessionService
|
||||||
WriteUsers();
|
WriteUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private StoredUser? GetUserById(string id)
|
private StoredUser GetUserById(string id)
|
||||||
{
|
{
|
||||||
var user = Users[id];
|
var user = Users[id];
|
||||||
return user;
|
return user;
|
||||||
|
|
|
@ -36,6 +36,14 @@
|
||||||
Loading = true;
|
Loading = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (Username == null || Password == null)
|
||||||
|
{
|
||||||
|
Loading = false;
|
||||||
|
Failure = true;
|
||||||
|
StateHasChanged(); // Manually triggering a state update, else component will not re-render.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var res = await Api.Auth.Login(new AuthRequest { Username = Username, Password = Password });
|
var res = await Api.Auth.Login(new AuthRequest { Username = Username, Password = Password });
|
||||||
switch (res.Status)
|
switch (res.Status)
|
||||||
{
|
{
|
||||||
|
@ -70,4 +78,5 @@
|
||||||
StateHasChanged(); // Manually triggering a state update, else component will not re-render.
|
StateHasChanged(); // Manually triggering a state update, else component will not re-render.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,28 +6,28 @@
|
||||||
@inject SessionService Session
|
@inject SessionService Session
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
<h3>Timeline</h3>
|
<h3>Timeline</h3>
|
||||||
@if (username != null)
|
@if (_username != null)
|
||||||
{
|
{
|
||||||
<span>You are logged in as @username </span>
|
<span>You are logged in as @_username </span>
|
||||||
<AuthorizeView>
|
<AuthorizeView>
|
||||||
<p>Authorization says you are @context.User.Identity!.Name</p>
|
<p>Authorization says you are @context.User.Identity!.Name</p>
|
||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
<button @onclick="Logout">Logout</button>
|
<button @onclick="Logout">Logout</button>
|
||||||
}else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
<span>Not logged in</span>
|
<span>Not logged in</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string? username;
|
private string? _username;
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
if (Session.Current != null)
|
if (Session.Current != null)
|
||||||
{
|
{
|
||||||
username = Session.Current.Username;
|
_username = Session.Current.Username;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,4 +36,5 @@
|
||||||
Session.EndSession();
|
Session.EndSession();
|
||||||
Navigation.NavigateTo("/login");
|
Navigation.NavigateTo("/login");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue