コード例 #1
0
        public User ResetPass(string email)
        {
            //check if email in database
            var Users        = _context.User.ToList();
            var isInDatabase = false;

            foreach (var us in Users)
            {
                if (us.Email == email)
                {
                    isInDatabase = true;
                }
            }

            if (isInDatabase == false)
            {
                return(new User());
            }
            else
            {
                var account = _context.User.FirstOrDefault(t => t.Email == email);



                //decriptam parola veche
                account.OldPassword = PassCrypt.DecryptString(account.Password);
                string ResetCode = Guid.NewGuid().ToString("N").Substring(0, 10);

                //schimbam parola veche cu una noua criptata
                account.Password = PassCrypt.EnryptString(ResetCode);
                _context.User.Update(account);
                _context.SaveChanges();

                int x = SendResetPasswordEmail(email, ResetCode);

                account.UserDetails = null;

                if (account.UserDetails != null)
                {
                    account.UserDetails.User = null;
                }
                account.ClientUserRel         = null;
                account.CourierUserRel        = null;
                account.ChatMessages          = null;
                account.CourierLocation       = null;
                account.ContactMessages       = null;
                account.ReportProblemMessages = null;
                account.DocImages             = null;

                account.Password = ResetCode;
                return(account);
            }
        }
コード例 #2
0
        public User LoginCourier(string email, string password)
        {
            string cryptPass = PassCrypt.EnryptString(password);

            var item = _context.User.Where(t => t.Email == email && t.Password == cryptPass && t.IsCurier == true).Include(x => x.UserDetails).FirstOrDefault();

            if (item != null)
            {
                item.Password         = PassCrypt.DecryptString(cryptPass);
                item.UserDetails.User = null;
            }
            return(item);
        }
コード例 #3
0
 public ActionResult Delete(int id)
 {
     using (MyDBContext dc = new MyDBContext())
     {
         var v = dc.User.Where(a => a.Id == id && a.IsCurier == false && a.Role != "admin").Include(x => x.UserDetails).FirstOrDefault();
         if (v != null)
         {
             v.Password = PassCrypt.DecryptString(v.Password);
             return(View(v));
         }
         else
         {
             return(HttpNotFound());
         }
     }
 }
コード例 #4
0
 public ActionResult Delete(int id)
 {
     using (MyDBContext dc = new MyDBContext())
     {
         var v = dc.User.Where(a => a.Id == id && a.IsCurier == true && a.Role != "admin").Include(x => x.UserDetails).Include(x => x.Car).FirstOrDefault();
         if (v != null)
         {
             v.Car.StringCarImage = "data:image/png;base64," + Convert.ToBase64String(v.Car.CarImage, 0, v.Car.CarImage.Length);
             v.Password           = PassCrypt.DecryptString(v.Password);
             return(View(v));
         }
         else
         {
             return(HttpNotFound());
         }
     }
 }
コード例 #5
0
 public ActionResult SaveOrUpdate(int id)
 {
     if (id != -1) //update
     {
         using (MyDBContext dc = new MyDBContext())
         {
             var v = dc.User.Where(a => a.Id == id && a.IsCurier == true && a.Role != "admin").Include(x => x.UserDetails).Include(x => x.Car).FirstOrDefault();
             v.Password = PassCrypt.DecryptString(v.Password);
             return(View(v));
         }
     }
     else // create
     {
         User v = new User();
         v.Id = -1;
         return(View(v));
     }
 }