Skip to content

Commit

Permalink
Merge pull request #151 from ministryofjustice/hotfix/user-registration
Browse files Browse the repository at this point in the history
Addresses issues with user registration
  • Loading branch information
vks333 authored Aug 20, 2024
2 parents dc9be25 + e2f8eb0 commit 26f1358
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 26f1358

Please sign in to comment.