Exemplo n.º 1
0
        public static void SendAuthCode(string Newpw, string Account)
        {
            User   data     = db.Users.Where(n => n.UserName == Account).FirstOrDefault();
            string AuthCode = Cls_JA_IDo.GetNewPW();
            string Email    = data.Email;

            data.VerificationCode = AuthCode;
            db.SaveChanges();
            Cls_JA_IDo.SendEmail(Email, Account, AuthCode);
        }
 public static bool UpdateUserPassword(int id, string newpw)
 {
     try
     {
         User   user = Cls_JA_Member.db.Users.Where(n => n.UserID == id).First();
         string guid = Guid.NewGuid().ToString("N");
         user.GUID         = guid;
         user.UserPassword = Cls_JA_IDo.HashPw(newpw, guid);
         Cls_JA_Member.db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 3
0
 public static void UpdatePassword(string NewPw, string Account)
 {
     try
     {
         var    data   = db.Users.FirstOrDefault(n => n.UserName == Account);
         string guid   = Guid.NewGuid().ToString("N");
         byte[] hashPw = Cls_JA_IDo.HashPw(NewPw, guid);
         data.UserPassword = hashPw;
         data.GUID         = guid;
         db.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 4
0
 public static bool UpdatePhone(string text)
 {
     if (!Cls_JA_IDo.IsValidPhone(text))
     {
         return(false);
     }
     try
     {
         var data = db.Users.FirstOrDefault(n => n.UserID == UserID);
         data.Phone = text;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 5
0
 public static bool ForgotPassword(string Account, string Email)
 {
     if (db.Users.Any(n => n.UserName == Account && n.Email == Email))
     {
         try
         {
             string newpw = Cls_JA_IDo.GetNewPW();
             Cls_JA_IDo.SendEmail(Email, Account, newpw);
             UpdatePassword(newpw, Account);
             return(true);
         }
         catch (Exception)
         {
             throw;
         }
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 6
0
 public static bool VaildateUser(string Username, string Password)
 {
     if (db.Users.Any(n => n.UserName == Username))
     {
         var    userdata = db.Users.Where(n => n.UserName == Username).First();
         byte[] p        = Cls_JA_IDo.HashPw(Password, userdata.GUID);
         if (BitConverter.ToString(p) == BitConverter.ToString(userdata.UserPassword))
         {
             UserID = userdata.UserID;
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }