コード例 #1
0
        /// <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());
        }
コード例 #2
0
        /// <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)));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
 .ForMember(x => x.PhoneNumber, o => o.MapFrom(claims => ClaimsHelper.GetValue <string>(claims, JwtClaimTypes.PhoneNumber)));
コード例 #7
0
 .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)))
コード例 #8
0
 .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)))
コード例 #9
0
 .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)))