Exemplo n.º 1
0
        public TokenModel GetToken(LoginCredentials loginCredentials)
        {
            var user = _unitOfWork.Repository <UserEntity>().Include(x => x.Profile).FirstOrDefault(x => x.Id == loginCredentials.Id && x.Confirmation.Confirmed);

            if (user == null)
            {
                return(null);
            }

            if (_cryptoContext.ArePasswordsEqual(loginCredentials.Password, user.Password, user.Salt))
            {
                return(_authTokenProvider.GetToken(user));
            }

            return(null);
        }
Exemplo n.º 2
0
        public TokenModel GetToken(LoginCredentials loginCredentials)
        {
            var user = unitOfWork.Repository <UserEntity>()
                       .Set
                       .FirstOrDefault(x => x.Email == loginCredentials.Email);

            if (user == null)
            {
                return(null);
            }

            if (cryptoContext.ArePasswordsEqual(loginCredentials.Password, user.Password, user.Salt))
            {
                return(BuildToken(user));
            }

            return(null);
        }