コード例 #1
0
ファイル: API.cs プロジェクト: Hansie211/Driessen-Groep
        public static async Task <APIResponse <string> > LoginUserAsync(string emailAddress, string password)
        {
            LoginUserParameters parameters = new LoginUserParameters()
            {
                EmailAddress = emailAddress,
                Password     = password,
            };

            return(await PostAsync <string>("api/users/login", parameters));
        }
コード例 #2
0
        public async Task <ActionResult <string> > LoginUser(LoginUserParameters parameters)
        {
            parameters.EmailAddress = parameters.EmailAddress.ToLower();

            var user = await Db.Users.FirstOrDefaultAsync(x => x.Email == parameters.EmailAddress);

            if (user == null)
            {
                return(BadRequest("Invalid emailadress / password"));
            }

            if (!PasswordSecurity.ComparePassword(parameters.Password, user))
            {
                return(BadRequest("Invalid emailadress / password"));
            }

            return(AccessToken.Generate(user.Email));
        }