Esempio n. 1
0
        public async Task<ActionResult> SetUserPassword(SetPasswordViewModel model)
        {
            UserManagement userMgr = new UserManagement(User.Identity.GetUserId<int>());
            try
            {
                BUser user = userMgr.GetUserInfo(model.Id);
                if (ModelState.IsValid)
                {
                    userMgr.DataProtectionProvider = Startup.DataProtectionProvider;
                    bool ret = await userMgr.SetUserPassword(model.Id, model.NewPassword);
                    //var result = await userMgr.AddPasswordAsync(User.Identity.GetUserId<int>(), model.NewPassword);
                    if (!user.IsAdmin)
                    {
                        return RedirectToAction("Agencies");
                    }
                    else
                    {
                        return RedirectToAction("Administrators");
                    }

                }
                else
                {

                    ViewBag.User = user;
                    return View(model);
                }

            }
            catch (KMBitException ex)
            {
                ViewBag.Message = ex.Message;
            }
            catch (Exception ex)
            {
            }

            return View("Error");
        }
Esempio n. 2
0
 public ActionResult SetUserPassword(int userId)
 {
     SetPasswordViewModel model = new SetPasswordViewModel() { Id = userId };
     UserManagement userMgr = new UserManagement(User.Identity.GetUserId<int>());
     BUser user = userMgr.GetUserInfo(userId);
     if(user!=null)
     {
         ViewBag.User = user;
         return View(model);
     }else
     {
         ViewBag.Message = string.Format("编号为{0}的用户不存在",userId);
         return View("Error");
     }           
 }