Skip to content

Commit

Permalink
Addresses issues with user registration
Browse files Browse the repository at this point in the history
- The phone number now saves on create
- Two factor auth is enabled by default
- Set all users to 'false' for export and import
  • Loading branch information
carlsixsmith-moj committed Aug 20, 2024
1 parent dc9be25 commit e2f8eb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public Mapping()
.ForMember(x => x.SuperiorName, s => s.MapFrom(y => y.Superior!.UserName))
.ForMember(x => x.TenantName, s => s.MapFrom(y => y.Tenant!.Name))
.ForMember(x => x.AssignedRoles, s => s.MapFrom(y => y.UserRoles.Select(r => r.Role.Name)))
.ForMember(x => x.PhoneNumber, s => s.MapFrom(x => x.PhoneNumber))
.ReverseMap()
.ForMember(x => x.UserName, s => s.MapFrom(y => y.Email))
.ForMember(x => x.Notes, s => s.Ignore())
Expand Down
8 changes: 6 additions & 2 deletions src/Server.UI/Pages/Identity/Users/Users.razor
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@
policies ??= new()
{
{ SecurityPolicies.SystemFunctionsWrite, (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.SystemFunctionsWrite)).Succeeded },
{ SecurityPolicies.Import, (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.Import)).Succeeded },
{ SecurityPolicies.Export, (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.Export)).Succeeded }
{ SecurityPolicies.Import, false /*(await AuthService.AuthorizeAsync(state.User, SecurityPolicies.Import)).Succeeded */ },
{ SecurityPolicies.Export, false /* (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.Export)).Succeeded */ }
};

_canCreate = policies.GetValueOrDefault(SecurityPolicies.SystemFunctionsWrite);
Expand Down Expand Up @@ -533,6 +533,8 @@
var applicationUser = Mapper.Map<ApplicationUser>(model);
applicationUser.EmailConfirmed = true;
applicationUser.IsActive = true;
applicationUser.TwoFactorEnabled = true;
applicationUser.PhoneNumberConfirmed = string.IsNullOrWhiteSpace(applicationUser.PhoneNumber) == false;

var identityResult = await UserManager.CreateAsync(applicationUser);
if (!identityResult.Succeeded)
Expand All @@ -556,6 +558,8 @@

Mapper.Map(model, user);

user.PhoneNumberConfirmed = string.IsNullOrWhiteSpace(user.PhoneNumber) == false;

var identityResult = await UserManager.UpdateAsync(user);
if (identityResult.Succeeded)
{
Expand Down

0 comments on commit e2f8eb0

Please sign in to comment.