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


            UserProfile profile = CurrentUserProfileOrThrow;

            GStoreData.Identity.AspNetIdentityUser aspUser = profile.AspNetIdentityUser();

            var model = new ProfileViewModel
            {
                HasPassword          = HasPassword(),
                PhoneNumber          = aspUser.PhoneNumber,
                TwoFactor            = await UserManager.GetTwoFactorEnabledAsync(User.Identity.GetUserId()),
                Logins               = await UserManager.GetLoginsAsync(User.Identity.GetUserId()),
                BrowserRemembered    = await AuthenticationManager.TwoFactorBrowserRememberedAsync(User.Identity.GetUserId()),
                EmailConfirmed       = aspUser.EmailConfirmed,
                PhoneNumberConfirmed = aspUser.PhoneNumberConfirmed,
                AspNetIdentityUser   = aspUser,
                UserProfile          = profile
            };

            return(View(model));
        }