コード例 #1
0
        public async Task<ActionResult> EditProfile(AccountProfileViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
            var oldEmail = user.Email;
            user.UserName = model.Email;
            user.Email = model.Email;
            user.DisplayName = model.DisplayName;
            var result = await UserManager.UpdateAsync(user);

            if (result.Succeeded)
            {
                await ResetMailEmailDestination(user, oldEmail);

                AuthenticationManager.SignOut();
                await SignInManager.SignInAsync(user, false, false);//.SignIn(new AuthenticationProperties { IsPersistent = false }, 
                //await user.GenerateUserIdentityAsync(UserManager);
                return RedirectToAction("Manage", new { Message = AccountMessageId.ProfileSaveSuccess });
            }
            return View(model);
        }
コード例 #2
0
 public ActionResult EditProfile()
 {
     var model = new AccountProfileViewModel { DisplayName = User.Identity.GetUserDisplayName(), Email = User.Identity.GetUserName() };
     return View(model);
 }