示例#1
0
        public async Task <IActionResult> ActivateUserAsync()
        {
            var userId = GetCurrentSaasUserId();

            await _memberService.ActivateMemberAsync(userId);

            return(Ok());
        }
示例#2
0
        public async Task ActivateMemberAsync_ShouldActivateMember()
        {
            var member = await _memberService.GetMemberByIdAsync(_memberId);

            Assert.False(member.IsActive);

            await _memberService.ActivateMemberAsync(member.SaasUserId);

            var activatedMember = await _memberService.GetMemberByIdAsync(_memberId);

            Assert.True(activatedMember.IsActive);
        }
        public async Task HandleAsync(AuthorizationHandlerContext context)
        {
            const string claimType       = "sub";
            var          saasUserIdClaim = context.User?.Claims.FirstOrDefault(x => x.Type == claimType);

            if (saasUserIdClaim == null)
            {
                return;
            }

            await _memberService.ActivateMemberAsync(saasUserIdClaim.Value);

            context.Succeed(new OperationAuthorizationRequirement());
        }