Ejemplo n.º 1
0
        public IActionResult Login([FromBody] LoginForm loginForm)
        {
            if (!(loginForm is null) && ModelState.IsValid)
            {
                loginForm.Passwd = _cryptoService.Decrypter(Convert.FromBase64String(loginForm.Passwd));

                try
                {
                    User user = _authRepository.Login(loginForm);
                    user = _authRepository.Authenticate(user);

                    if (user.Id == 0)
                    {
                        return(NoContent());
                        //return BadRequest(new { message = "Wrong email or password" }); ////*** AuthRequester
                    }
                    else
                    {
                        return(Ok(user));
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest());
                }
            }
            return((!(loginForm is null)) ? BadRequest(ModelState) : BadRequest("There is no Data !"));
        }