2023-02-12 16:01:46 +00:00
|
|
|
@page "/sys/you"
|
2023-02-12 18:06:33 +00:00
|
|
|
@using ImageBoardServerApp.Auth
|
|
|
|
@using ImageBoardServerApp.Data.Repository
|
|
|
|
@inject AuthenticationStateProvider authStateProvider
|
|
|
|
@inject NavigationManager navManager
|
2023-02-12 16:01:46 +00:00
|
|
|
|
2023-06-08 21:34:59 +00:00
|
|
|
<PageTitle>YOU - Bulletboards</PageTitle>
|
|
|
|
|
2023-02-12 18:06:33 +00:00
|
|
|
<AuthorizeView>
|
|
|
|
<Authorized>
|
|
|
|
<h3>YOU</h3>
|
|
|
|
<br/>
|
|
|
|
<span>Email: @mail</span>
|
|
|
|
<br/>
|
|
|
|
<span>Email: </span>
|
|
|
|
<input type="email" id="email" @bind="newMail" />
|
|
|
|
<a @onclick="changeEmail" href="javascript:void(0)">[Change Email]</a>
|
|
|
|
<br/>
|
2023-06-12 10:25:48 +00:00
|
|
|
<a href="/sys/resetpw">[Change Password]</a>
|
2023-02-12 18:06:33 +00:00
|
|
|
<br/>
|
2023-06-08 21:34:59 +00:00
|
|
|
<a href="/sys/logout">[Logout]</a>
|
2023-02-12 18:06:33 +00:00
|
|
|
</Authorized>
|
|
|
|
<NotAuthorized>
|
|
|
|
<span>You are not logged in.</span>
|
|
|
|
<a class="navbar-brand" href="/sys/login">Please login first.</a>
|
|
|
|
</NotAuthorized>
|
|
|
|
</AuthorizeView>
|
2023-02-13 17:45:14 +00:00
|
|
|
|
2023-02-12 16:01:46 +00:00
|
|
|
@code {
|
|
|
|
|
2023-02-12 18:06:33 +00:00
|
|
|
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;
|
2023-06-09 07:45:14 +00:00
|
|
|
UserData foundusr = await UsersRepository.getUserByIdAsync(int.Parse(usr.Identity.Name));
|
2023-02-12 18:06:33 +00:00
|
|
|
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);
|
|
|
|
}
|
2023-02-12 16:01:46 +00:00
|
|
|
}
|