Esempio n. 1
0
        public int UpdatePassword(string phoneNumber, List <string> passwords)
        {
            var account = _context.Accounts.FirstOrDefault(x => x.PhoneNum == phoneNumber);

            if (account != null)
            {
                if (BcryptPass.ValidatePassword(passwords[0], account.Password))
                {
                    account.Password = BcryptPass.HashPassword(passwords[1]);
                    try
                    {
                        _context.SaveChanges();
                        return(1);
                    }
                    catch (Exception)
                    {
                        return(-1);
                    }
                }
                else
                {
                    return(0);
                }
            }
            return(-1);
        }
Esempio n. 2
0
        public int Login(string phoneNumber, string password)
        {
            var user = _context.Accounts.FirstOrDefault(x => x.PhoneNum == phoneNumber);

            if (user == null)
            {
                return(0);
            }
            if (BcryptPass.ValidatePassword(password, user.Password))
            {
                return(1);
            }
            return(-1);
        }