예제 #1
0
파일: Login.cs 프로젝트: nearcoding/GAP
        public bool Authenticate(string email, string password)
        {
            try
            {
                GAP.DAL.LoginModelDataContext loginmdc = new GAP.DAL.LoginModelDataContext();
                string salt = loginmdc.GetSalt(email);
                string dbpass = loginmdc.GetPassword(email);

                if (salt != string.Empty && dbpass != string.Empty)
                {

                    Helpers.Login_Security sec = new Helpers.Login_Security();

                    string hashedpassword = sec.hashPass(salt, password);

                    if (dbpass == hashedpassword)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }
            catch (Exception)
            {                
                return false;
            }
        }
예제 #2
0
파일: Login.cs 프로젝트: nearcoding/GAP
        public bool ResetPassword(string email)
        {
            try
            {
                GAP.DAL.LoginModelDataContext resetpsw = new GAP.DAL.LoginModelDataContext();
                Login_Security sec = new Login_Security();
                EmailSender sender = new EmailSender();
                if (EmailExists(email))
                {
                    string salt = resetpsw.GetSalt(email);
                    string clearpass = sec.RandomString();

                    string hashedpassword = sec.hashPass(salt, clearpass);

                    if (resetpsw.UpdatePassword(email, hashedpassword, salt))
                    {
                        sender.ResetPassword(email, clearpass);
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }