Exemple #1
0
        public Tuple <string, string, string, string> Login(string email, string password)
        {
            // first use email to retrieve user info;
            var customer = _customer.GetCustomer(email);

            if (customer == null)
            {
                throw new InvalidOperationException("Customer Does not Exist");
            }

            if (!PasswordHash.CompareHash(customer.PasswordSalt, customer.PasswordHash, password))
            {
                throw new ArgumentException("Incorrect Password");
            }
            LoginCredential = new Tuple <string, string, string, string>(customer.Id, customer.Email, customer.LastName, customer.FirstName);

            return(LoginCredential);
        }
 public Task <DataToken> UserLogin(LoginData login)
 {
     return(Task.Run(() =>
     {
         User user = _db.Users.Where(e => e.Email == login.Email).FirstOrDefault();
         if (user != null)
         {
             if (PasswordHash.CompareHash(login.Password, user.Password))
             {
                 return new DataToken()
                 {
                     Token = _generateToken(user.Id),
                     RefreshToken = _generateRefreshToken(user.Id)
                 };
             }
         }
         return null;
     }));
 }