Exemplo n.º 1
0
        public BaseResponse <string> Login(string email, string password)
        {
            try
            {
                var user = _userRepository.GetUserByEmail(email);
                if (user == null)
                {
                    return(new BaseResponse <string>().Error("User not found."));
                }

                var passwordEncrypt = CryptographyService.GetMd5Hash(password);
                if (user.Password != passwordEncrypt)
                {
                    return(new BaseResponse <string>().Error("Invalid User/Password."));
                }

                var token = _jwtTokenService.GererateToken(user);
                return(new BaseResponse <string>(token, true));
            }
            catch (Exception ex)
            {
                return(new BaseResponse <string>().Error(ex.Message));
            }
        }