Ejemplo n.º 1
0
        public ActionResult ChangePassword(string oldpassword, string newpassword)
        {
            var user = SSOProviders.Current.GetUser();

            SSO.Services.UserService userService = new SSO.Services.UserService();
            try
            {
                if (user.Password != oldpassword)
                {
                    throw new Exception("原密码不正确");
                }
                if (string.IsNullOrWhiteSpace(newpassword))
                {
                    throw new Exception("密码不能为空");
                }
                ViewBag.message = "密码修改成功。";
                user.Password   = newpassword;
                userService.Update(user);
            }
            catch (Exception err)
            {
                ModelState.AddModelError("", err.Message);
            }
            return(View(user));
        }
Ejemplo n.º 2
0
        public ActionResult Info(SSO.Models.User model)
        {
            var user = SSOProviders.Current.GetUser();

            SSO.Services.UserService userService = new SSO.Services.UserService();
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("模型验证不通过");
                }
                user.NickName = model.NickName;
                user.Mail     = model.Mail;
                user.Tell     = model.Tell;
                userService.Update(user);

                ViewBag.message = "信息修改成功。";
            }
            catch (Exception err)
            {
                ModelState.AddModelError("", err.Message);
            }
            return(View(user));
        }