/// <inheritdoc /> public ApplicationUserMapperConfiguration() { CreateMap <RegisterViewModel, ApplicationUser>() .ForMember(x => x.UserName, o => o.MapFrom(p => p.Email)) .ForMember(x => x.Email, o => o.MapFrom(p => p.Email)) .ForMember(x => x.EmailConfirmed, o => o.MapFrom(src => true)) .ForMember(x => x.FirstName, o => o.MapFrom(p => p.FirstName)) .ForMember(x => x.LastName, o => o.MapFrom(p => p.LastName)) .ForMember(x => x.PhoneNumberConfirmed, o => o.MapFrom(src => true)) .ForAllOtherMembers(x => x.Ignore()); CreateMap <ClaimsIdentity, ApplicationUserProfileViewModel>() .ForMember(x => x.Id, o => o.MapFrom(claims => ClaimsHelper.GetValue <Guid>(claims, JwtClaimTypes.Subject))) .ForMember(x => x.PositionName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, ClaimTypes.Actor))) .ForMember(x => x.FirstName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.GivenName))) .ForMember(x => x.LastName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, ClaimTypes.Surname))) .ForMember(x => x.Roles, o => o.MapFrom(claims => ClaimsHelper.GetValues <string>(claims, JwtClaimTypes.Role))) .ForMember(x => x.Email, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.Name))) .ForMember(x => x.EmailVerified, o => o.MapFrom(claims => ClaimsHelper.GetValue <bool>(claims, JwtClaimTypes.EmailVerified))) .ForMember(x => x.PreferredUserName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.PreferredUserName))) .ForMember(x => x.PhoneNumber, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.PhoneNumber))) .ForMember(x => x.PhoneNumberVerified, o => o.MapFrom(claims => ClaimsHelper.GetValue <bool>(claims, JwtClaimTypes.PhoneNumberVerified))) .ForMember(x => x.AdditionalEmails, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, "AdditionalEmails"))) .ForAllOtherMembers(x => x.Ignore()); }
/// <inheritdoc /> public ProfilesMapperConfiguration() { CreateMap <RegisterViewModel, ApplicationUser>() .ForMember(x => x.UserName, o => o.MapFrom(p => p.Email)) .ForMember(x => x.Email, o => o.MapFrom(p => p.Email)) .ForMember(x => x.EmailConfirmed, o => o.MapFrom(src => true)) .ForMember(x => x.FirstName, o => o.MapFrom(p => p.FirstName)) .ForMember(x => x.LastName, o => o.MapFrom(p => p.LastName)) .ForMember(x => x.PhoneNumberConfirmed, o => o.MapFrom(src => true)) .ForMember(x => x.ApplicationUserProfileId, o => o.Ignore()) .ForMember(x => x.ApplicationUserProfile, o => o.Ignore()) .ForMember(x => x.Id, o => o.Ignore()) .ForMember(x => x.NormalizedUserName, o => o.Ignore()) .ForMember(x => x.NormalizedEmail, o => o.Ignore()) .ForMember(x => x.PasswordHash, o => o.Ignore()) .ForMember(x => x.SecurityStamp, o => o.Ignore()) .ForMember(x => x.ConcurrencyStamp, o => o.Ignore()) .ForMember(x => x.PhoneNumber, o => o.Ignore()) .ForMember(x => x.TwoFactorEnabled, o => o.Ignore()) .ForMember(x => x.LockoutEnd, o => o.Ignore()) .ForMember(x => x.LockoutEnabled, o => o.Ignore()) .ForMember(x => x.AccessFailedCount, o => o.Ignore()); CreateMap <ClaimsIdentity, UserProfileViewModel>() .ForMember(x => x.Id, o => o.MapFrom(claims => ClaimsHelper.GetValue <Guid>(claims, JwtClaimTypes.Subject))) .ForMember(x => x.PositionName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, ClaimTypes.Actor))) .ForMember(x => x.FirstName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.GivenName))) .ForMember(x => x.LastName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, ClaimTypes.Surname))) .ForMember(x => x.Roles, o => o.MapFrom(claims => ClaimsHelper.GetValues <string>(claims, JwtClaimTypes.Role))) .ForMember(x => x.Email, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.Name))) .ForMember(x => x.PhoneNumber, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.PhoneNumber))); }
public async Task <IActionResult> CognitoEditCash([FromBody] User userInfo) { UserDynamo UserUpdate = new UserDynamo { Cash = userInfo.Cash, Email = ClaimsHelper.GetValue(HttpContext) }; await _DBDynamo.Update(UserUpdate); return(Ok(UserUpdate)); }
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement) { var identity = (ClaimsIdentity)context.User.Identity !; var claim = ClaimsHelper.GetValue <string>(identity, requirement.PermissionName); if (claim == null) { return(Task.CompletedTask); } context.Succeed(requirement); return(Task.CompletedTask); }
public async Task <IActionResult> Bet([FromBody] RouletteBet Bet) { var tokenEmailSession = new UserDynamo { Email = ClaimsHelper.GetValue(HttpContext) }; UserDynamo userInfo = await _DBDynamo.Get(tokenEmailSession); if (Quantity.IsBigger(baseValue: Bet.Player.Cash, comparedValue: userInfo.Cash)) { return(BadRequest("Not enough cash. Charge your account and try later please.")); } Bet.Player.Email = userInfo.Email; var jsonObject = JsonConvert.SerializeObject(Bet); await _Queue.SendMessageAsync(message : jsonObject, sqsUrl : sqsBet); return(StatusCode(201, Bet)); }
.ForMember(x => x.PhoneNumber, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.PhoneNumber)));
.ForMember(x => x.LastName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, ClaimTypes.Surname))) .ForMember(x => x.Roles, o => o.MapFrom(claims => ClaimsHelper.GetValues <string>(claims, JwtClaimTypes.Role)))
.ForMember(x => x.PositionName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, ClaimTypes.Actor))) .ForMember(x => x.FirstName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.GivenName)))
.ForMember(x => x.Id, o => o.MapFrom(claims => ClaimsHelper.GetValue <Guid>(claims, JwtClaimTypes.Subject))) .ForMember(x => x.PositionName, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, ClaimTypes.Actor)))