add role api
This commit is contained in:
@@ -94,8 +94,10 @@ public class UserManagerService
|
||||
data["password"] = JsonDocument.Parse($"\"{Guid.NewGuid().ToString().Substring(0, 8)}\"").RootElement;
|
||||
}
|
||||
|
||||
var PasswordHash = data.ContainsKey("password") ? PasswordHasher.Hash(data["password"].GetString()!) : null;
|
||||
var RawPassword = data["password"].GetString()!;
|
||||
var PasswordHash = PasswordHasher.Hash(RawPassword);
|
||||
|
||||
var sendCredentialsEmail = !data.ContainsKey("sendCredentialsEmail") || data["sendCredentialsEmail"].GetBoolean();
|
||||
|
||||
// Create User object
|
||||
User user = new User
|
||||
@@ -113,7 +115,7 @@ public class UserManagerService
|
||||
IsLocked = false,
|
||||
EmailVerified = false,
|
||||
MobileNumberVerified = false,
|
||||
//PasswordHash = PasswordHash
|
||||
PasswordHash = PasswordHash
|
||||
|
||||
};
|
||||
|
||||
@@ -151,6 +153,30 @@ public class UserManagerService
|
||||
|
||||
await _uow.CommitAsync();
|
||||
|
||||
if (sendCredentialsEmail && !string.IsNullOrWhiteSpace(Email))
|
||||
{
|
||||
try
|
||||
{
|
||||
await _thirdPartyService.EmailConfiguration(
|
||||
Email,
|
||||
RawPassword,
|
||||
"Your ERP System Account",
|
||||
$@"
|
||||
<html>
|
||||
<body style='font-family: Arial, sans-serif;'>
|
||||
<h2>Your ERP System account has been created</h2>
|
||||
<p>Username: <strong>{WebUtility.HtmlEncode(UserName ?? Email)}</strong></p>
|
||||
<p>Temporary password: <strong>{{code}}</strong></p>
|
||||
<p>Please log in and change your password as soon as possible.</p>
|
||||
</body>
|
||||
</html>");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Best-effort: account creation already committed; do not fail the request on email delivery issues.
|
||||
}
|
||||
}
|
||||
|
||||
return new
|
||||
{
|
||||
AccessToken = jwtToken,
|
||||
@@ -544,6 +570,17 @@ public class UserManagerService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<object> ListUserTypes(HttpContext httpContext)
|
||||
{
|
||||
var userTypes = await _dbContext.UserType.OrderBy(t => t.Code).ToListAsync();
|
||||
return userTypes.Select(t => new
|
||||
{
|
||||
t.UserTypeId,
|
||||
t.Code,
|
||||
t.Description
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public async Task<object> GetUserSessions(HttpContext httpContext)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user