Beispiel #1
0
        public ActionResult ChangeProfile(FormChangeUser u)
        {
            User user = (User)Session[KeysUtils.SessionUser()];

            if (!user.email.Trim().Equals(u.email) && Models.User.EmailExists(u.email))
            {
                ModelState.AddModelError("EmailExists", "Email already exists");
            }
            else
            {
                if (u.password == null || u.password.Trim().Equals(""))
                {
                    u.password = ((User)(Session[KeysUtils.SessionUser()])).password;
                }
                else
                {
                    user.password = CryptUtils.Hash(u.password);
                }
                user.email      = u.email;
                user.first_name = u.firstName;
                user.last_name  = u.lastName;
                user.saveChanges();
                Session[KeysUtils.SessionUser()] = user;
                ViewBag.Status  = true;
                ViewBag.Message = "Changed profile  successfully";
            }



            return(View(u));
        }
Beispiel #2
0
        public static User CreateFrom(FormRegisterUser fr)
        {
            User u = new User();

            u.password   = CryptUtils.Hash(fr.password);
            u.email      = fr.email;
            u.last_name  = fr.lastName;
            u.first_name = fr.firstName;
            u.tokens     = 0;
            u.admin_flag = false;
            return(u);
        }
Beispiel #3
0
 public Boolean ValidatePassword(String pass)
 {
     return(String.Equals(this.password, CryptUtils.Hash(pass)));
 }