@page "/sys/you"
@using ImageBoardServerApp.Auth
@using ImageBoardServerApp.Data.Repository
@inject AuthenticationStateProvider authStateProvider
@inject NavigationManager navManager
YOU - Bulletboards
YOU
Email: @mail
Email:
[Change Email]
[Change Password]
[Logout]
You are not logged in.
Please login first.
@code {
private string mail { get; set; } = "";
private string newMail { get; set; }
protected override async Task OnInitializedAsync()
{
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
var user = await cauthStateProvder.GetAuthenticationStateAsync();
if (user.User.Identity.IsAuthenticated)
{
mail = user.User.Identity.Name;
}
}
private async Task changeEmail()
{
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
var user = await cauthStateProvder.GetAuthenticationStateAsync();
var usr = user.User;
UserData foundusr = await UsersRepository.getUserByIdAsync(int.Parse(usr.Identity.Name));
if (foundusr == null)
{
return;
}
int userID = foundusr.UserID;
if (newMail == null || newMail == "" || !newMail.Contains("@"))
{
return;
}
foundusr.Email = newMail;
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
await UsersRepository.updateUserAsync(foundusr);
}
}