Beispiel #1
0
        public async Task <Result <TokenAuth> > Logar(AuthUser user)
        {
            if (user == null || user.UsuarioInvalido())
            {
                return(new Result <TokenAuth>(new [] { "Email ou Password inválidos" }));
            }

            var userAuth = await _authRepositorio.Logar(user);

            if (userAuth == null)
            {
                return(new Result <TokenAuth>(new[] { "Email ou Password inválidos" }));
            }

            return(new Result <TokenAuth>(new TokenAuth
            {
                access_token = _jwtService.GenerateToken(userAuth)
            }));
        }