Пример #1
0
        public async Task <LoginResult> RefreshToken()
        {
            var userInfo = UserQueryService.GetUserByEmail(User.Identity.Name);

            if (userInfo == null)
            {
                throw new ApiException("User not exists", 500);
            }
            return(await GenerateToken(userInfo));
        }
Пример #2
0
        public async Task <LoginResult> Login([FromQuery] string email, [FromQuery] string passwordHash, [FromHeader] string token)
        {
            var userInfo = UserQueryService.GetUserByEmail(email);

            if (userInfo == null)
            {
                throw new ApiException("User not exists", 500);
            }

            if (!string.Equals(passwordHash, userInfo.PasswordHash, StringComparison.OrdinalIgnoreCase))
            {
                throw new ApiException("Authentication Fail, Please confirm your username and password", 500);
            }

            return(await GenerateToken(userInfo, true));
        }