username change panel added

This commit is contained in:
2024-11-06 00:11:45 +01:00
Unverified
parent 26a5e1e558
commit 4cbc44f9be
21 changed files with 305 additions and 42 deletions

View File

@@ -240,7 +240,9 @@ public class AccountsControllerService(
}
#endregion
#region Info
public async Task<RequestResult> GetAccountInfo(long id)
{
Account? account = await database.Accounts.FirstOrDefaultAsync(x => x.Id == id);
@@ -266,6 +268,23 @@ public class AccountsControllerService(
return RequestResult.Ok();
}
public async Task<RequestResult> PatchAccountUsername(AccountUsernameRequest data)
{
Account account = await database.Accounts.FirstAsync(x => x.Id == userService.GetUserId());
if (!ComputeHash(data.Password, account.LeftSalt, account.RightSalt).SequenceEqual(account.Password))
{
return RequestResult.Unauthorized();
}
data.UpdateAccount(account);
await database.SaveChangesAsync();
return RequestResult.Ok();
}
#endregion
public async Task<RequestResult> GetAccountRatedMovies(long id, MovieRatedQueryParameters query)
{

View File

@@ -21,6 +21,7 @@ public interface IAccountsControllerService
Task<RequestResult> DeleteAccountProfileBackground();
Task<RequestResult> GetAccountInfo(long id);
Task<RequestResult> PutAccountProfileInfo(AccountProfileInfoRequest data);
Task<RequestResult> PatchAccountUsername(AccountUsernameRequest data);
Task<RequestResult> GetAccountRatedMovies(long id, MovieRatedQueryParameters query);
Task<RequestResult> GetAccountRatedSeries(long id, SeriesRatedQueryParameters query);
Task<RequestResult> GetAccountRatedPersons(long id, PersonRatedQueryParameters query);