Ejemplo n.º 1
0
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : "";

            var userId      = User.Identity.GetUserId();
            var currentUser = AplicationUserService.FindById(userId);

            var model = new ManageIndexViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await AplicationUserService.GetPhoneNumberAsync(userId),
                TwoFactor         = await AplicationUserService.GetTwoFactorEnabledAsync(userId),
                Logins            = await AplicationUserService.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId),
                AvatarId          = currentUser.PictureId,
                AvatarUrl         = mediaStorageService.GetPictureUrl(currentUser.PictureId),
                UserName          = currentUser.UserName,
                Email             = currentUser.Email,
                Description       = currentUser.Description,
                Roles             = string.Join(", ", AplicationUserService.GetRoles(userId).ToArray())
            };

            return(RedirectToAction("UserEdit", new { Id = userId }));
        }