Ejemplo n.º 1
0
        public async Task <ActionResult <UserAuthorizationModel> > VerifyAuthentication() => await Execute(async operation =>
        {
            var userId = AuthenticationUtils.GetUserId(User.Claims);
            if (userId == null)
            {
                throw CommonExceptions.AccessDenied(operation, StatusCodes.Status401Unauthorized);
            }

            if (!await authenticationService.IsUserActivated(operation, userId.Value))
            {
                throw CommonExceptions.AccessDenied(operation, StatusCodes.Status401Unauthorized, true);
            }

            return(new UserAuthorizationModel
            {
                Id = userId.Value,
                Permissions = AuthenticationUtils.GetUserPermissions(User.Claims)
            });
        });