コード例 #1
0
        public async Task <UserAuthInfo> CreateUserInfo(string userId, string login, string password)
        {
            var userInfo = new UserAuthInfo
            {
                Id           = userId,
                Login        = login,
                PasswordHash = password,
            };

            await _connection.StoreAsync(userInfo);

            await _connection.SaveChangesAsync();

            return(userInfo);
        }
コード例 #2
0
        public async Task <ActionResult> Login([FromBody] LoginDto loginDto)
        {
            string login    = loginDto.Login;
            string password = loginDto.Password;

            UserAuthInfo user = await _authenticationService.LoginAsync(login, password);

            if (user == null)
            {
                return(NotFound("user with this credentials not found"));
            }

            await AuthenticateUser(user.Id);

            SetUserIdHeader(user.Id);

            return(Ok(user.Id));
        }