Roles #21
@@ -63,31 +63,31 @@ public class UserService : BaseService, IUserService
|
|||||||
|
|
||||||
|
|
||||||
public async Task<User?> GetUserByIdAsync(int id)
|
public async Task<User?> GetUserByIdAsync(int id)
|
||||||
{
|
{ //NOSONAR
|
||||||
return await this.GetUsersQueryable().Where(x => x.Id == id).FirstOrDefaultAsync();
|
return await this.GetUsersQueryable().Where(x => x.Id == id).FirstOrDefaultAsync();
|
||||||
}
|
} //NOSONAR
|
||||||
|
|
||||||
public async Task<User?> GetUserByGuidAsync(string guid)
|
public async Task<User?> GetUserByGuidAsync(string guid)
|
||||||
{
|
{ //NOSONAR
|
||||||
return await this.GetUsersQueryable().Where(x => x.Guid == guid).FirstOrDefaultAsync();
|
return await this.GetUsersQueryable().Where(x => x.Guid == guid).FirstOrDefaultAsync();
|
||||||
}
|
} //NOSONAR
|
||||||
|
|
||||||
public async Task<User?> GetUserByEmailAsync(string email)
|
public async Task<User?> GetUserByEmailAsync(string email)
|
||||||
{
|
{ //NOSONAR
|
||||||
return await this.GetUserByEmailQueryable(email).FirstOrDefaultAsync();
|
return await this.GetUserByEmailQueryable(email).FirstOrDefaultAsync();
|
||||||
}
|
} //NOSONAR
|
||||||
|
|
||||||
public async Task<User?> GetUserByUsernameAndPassword(string email, string password)
|
public async Task<User?> GetUserByUsernameAndPassword(string email, string password)
|
||||||
{
|
{ //NOSONAR
|
||||||
User? user = await this.GetUserByEmailQueryable(email).FirstOrDefaultAsync();
|
User? user = await this.GetUserByEmailQueryable(email).FirstOrDefaultAsync();
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{ //NOSONAR
|
||||||
var encryptedPassword = user.PasswordHash;
|
var encryptedPassword = user.PasswordHash;
|
||||||
Console.WriteLine(encryptedPassword);
|
Console.WriteLine(encryptedPassword);
|
||||||
}
|
} //NOSONAR
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
} //NOSONAR
|
||||||
|
|
||||||
public async Task<bool> CheckIfEmailIsValid(string email, string? guid = "")
|
public async Task<bool> CheckIfEmailIsValid(string email, string? guid = "")
|
||||||
{
|
{
|
||||||
@@ -113,9 +113,9 @@ public class UserService : BaseService, IUserService
|
|||||||
using var transaction = await _sqlServerContext.Database.BeginTransactionAsync();
|
using var transaction = await _sqlServerContext.Database.BeginTransactionAsync();
|
||||||
|
|
||||||
User? user;
|
User? user;
|
||||||
|
var tempUser = CreateUserData(data, role);
|
||||||
try
|
try
|
||||||
{ //NOSONAR
|
{ //NOSONAR
|
||||||
var tempUser = CreateUserData(data, role);
|
|
||||||
await _sqlServerContext.Users.AddAsync(tempUser);
|
await _sqlServerContext.Users.AddAsync(tempUser);
|
||||||
await _sqlServerContext.SaveChangesAsync();
|
await _sqlServerContext.SaveChangesAsync();
|
||||||
await transaction.CommitAsync();
|
await transaction.CommitAsync();
|
||||||
|
|||||||
Reference in New Issue
Block a user