예제 #1
0
 public bool ChangePW(string Email, string OldPW, string NewPW)
 {
     try
     {
         int    id      = Int32.Parse(upid);
         string oldguid = db.Users.Find(id).GUID;
         byte[] oldpp   = MemberMethod.HashPw(OldPW, oldguid);
         if (db.Users.Any(n => n.Email == Email && n.UserPassword == oldpp))
         {
             User   user    = db.Users.Find(id);
             string NewGUID = Guid.NewGuid().ToString("N");
             user.UserPassword = MemberMethod.HashPw(NewPW, NewGUID);
             user.GUID         = NewGUID;
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         string me = ex.Message;
         return(false);
     }
 }
예제 #2
0
 public string LoginCheck(string UserName, string Password)
 {
     if (db.Users.Any(m => m.UserName == UserName))
     {
         User   LoginUser = db.Users.Where(m => m.UserName == UserName).FirstOrDefault();
         byte[] pw        = MemberMethod.HashPw(Password, LoginUser.GUID);
         upid = LoginUser.UserID.ToString();
         if (!LoginUser.Enabled)
         {
             return("noenabled");
         }
         if (BitConverter.ToString(pw) == BitConverter.ToString(LoginUser.UserPassword) &&
             LoginUser.VerificationCode == String.Empty)
         {
             return("islogin");
         }
         else
         {
             return("nologin");
         }
     }
     else
     {
         return("nologin");
     }
 }
예제 #3
0
 public string UpdatePassword(string NewPw, string Account)
 {
     try
     {
         var    data            = db.Users.FirstOrDefault(n => n.UserName == Account);
         string guid            = Guid.NewGuid().ToString("N");
         string newverification = MemberMethod.GetNewPW();
         byte[] hashPw          = MemberMethod.HashPw(NewPw, guid);
         data.UserPassword     = hashPw;
         data.GUID             = guid;
         data.VerificationCode = newverification;
         db.SaveChanges();
         return(newverification);
     }
     catch (Exception)
     {
         throw;
     }
 }