コード例 #1
0
        //
        // GET: /Manage/Index
        public async Task<ActionResult> Index(ManageMessageId? message)
        {
            this.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 = this.User.Identity.GetUserId();
            var model = new IndexViewModel
                        {
                            HasPassword = this.HasPassword(),
                            PhoneNumber = await this.UserManager.GetPhoneNumberAsync(userId),
                            TwoFactor = await this.UserManager.GetTwoFactorEnabledAsync(userId),
                            Logins = await this.UserManager.GetLoginsAsync(userId),
                            BrowserRemembered =
                                await
                                this.AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
                        };
            return this.View(model);
        }
コード例 #2
0
        // GET: /Manage/Index
        public async Task<ActionResult> Index(ManageMessageId? message)
        {
            this.ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." 
                                       : message == ManageMessageId.Error ? "An error has occurred."
                                       : message == ManageMessageId.ChangeEmailSuccess ? "Your email was changed."
                                       : string.Empty;

            var userId = this.User.Identity.GetUserId();
            var model = new IndexViewModel
                            {
                                HasPassword = this.HasPassword(), 
                                PhoneNumber = await this.UserManager.GetPhoneNumberAsync(userId), 
                                TwoFactor = await this.UserManager.GetTwoFactorEnabledAsync(userId), 
                                Logins = await this.UserManager.GetLoginsAsync(userId), 
                                BrowserRemembered =
                                    await
                                    this.AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
                            };
            return this.View(model);
        }