• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# VerifyPhoneNumberViewModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中VerifyPhoneNumberViewModel的典型用法代码示例。如果您正苦于以下问题:C# VerifyPhoneNumberViewModel类的具体用法?C# VerifyPhoneNumberViewModel怎么用?C# VerifyPhoneNumberViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VerifyPhoneNumberViewModel类属于命名空间,在下文中一共展示了VerifyPhoneNumberViewModel类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VerifyPhoneNumber

 public async Task<IActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = await GetCurrentUserAsync();
     if (user != null)
     {
         var result = await _userManager.ChangePhoneNumberAsync(user, model.PhoneNumber, model.Code);
         if (result.Succeeded)
         {
             await _signInManager.SignInAsync(user, isPersistent: false);
             return RedirectToAction(nameof(Index), new { Message = ManageMessageId.AddPhoneSuccess });
         }
     }
     // If we got this far, something failed, redisplay the form
     ModelState.AddModelError(string.Empty, "Failed to verify phone number");
     return View(model);
 }
开发者ID:PMelia07,项目名称:Personal-Website,代码行数:20,代码来源:ManageController.cs


示例2: VerifyPhoneNumber

 public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
     }
     // If we got this far, something failed, redisplay form
     ModelState.AddModelError("", "Failed to verify phone");
     return View(model);
 }
开发者ID:archlicher,项目名称:ASP.NET,代码行数:20,代码来源:ManageController.cs


示例3: VerifyPhoneNumber

        public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View(model);
            }

            var result = await this.UserManager.ChangePhoneNumberAsync(this.User.Identity.GetUserId(), model.PhoneNumber, model.Code);
            if (result.Succeeded)
            {
                var user = await this.UserManager.FindByIdAsync(this.User.Identity.GetUserId());
                if (user != null)
                {
                    await this.SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                }

                return this.RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
            }

            this.ModelState.AddModelError(string.Empty, "Failed to verify phone");
            return this.View(model);
        }
开发者ID:shunobaka,项目名称:Interapp,代码行数:22,代码来源:ManageController.cs


示例4: VerifyPhoneNumber

 public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
     }
     // Si llegamos a este punto, es que se ha producido un error, volvemos a mostrar el formulario
     ModelState.AddModelError("", "No se ha podido comprobar el teléfono");
     return View(model);
 }
开发者ID:Randy-ak47,项目名称:CursoPooNet,代码行数:20,代码来源:ManageController.cs


示例5: VerifyPhoneNumber

 public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
     }
     // Это сообщение означает наличие ошибки; повторное отображение формы
     ModelState.AddModelError("", "Не удалось проверить телефон");
     return View(model);
 }
开发者ID:MViter,项目名称:web_chat_apriorit_team,代码行数:20,代码来源:ManageController.cs


示例6: VerifyPhoneNumber

 public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
     }
     // 如果我们进行到这一步时某个地方出错,则重新显示表单
     ModelState.AddModelError("", "无法验证电话号码");
     return View(model);
 }
开发者ID:jerviscui,项目名称:FirstWebFramework,代码行数:20,代码来源:ManageController.cs


示例7: VerifyPhoneNumber

        public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            ObjectId userId = User.Identity.GetUserId2<ObjectId>();
            IdentityResult result = await _userManager.ChangePhoneNumberAsync(userId
                , model.PhoneNumber, model.Code);

            if (result.Succeeded)
            {
                var user = await _userManager.FindByIdAsync(User.Identity.GetUserId2<ObjectId>());
                if (user != null)
                {
                    await SignInAsync(user, isPersistent: false);
                }
                return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
            }

            // If we got this far, something failed, redisplay form
            string errorMessage = IdentityResourceHelper.Load(IdentitySettings.IdentityResource, "ManageController_VerifyPhoneNumber_Error");
            ModelState.AddModelError("", errorMessage);
            return View(model);
        }
开发者ID:RodionKulin,项目名称:ContentManagementBackend,代码行数:26,代码来源:ManageController.cs


示例8: VerifyPhoneNumber

        public void VerifyPhoneNumber(
         VerifyPhoneNumberViewModel model,
         ModelMethodContext context)
        {
            if (!context.ModelState.IsValid) return;

             var userId = _context.User.Identity.GetUserId();
             var result = _userManager.ChangePhoneNumber(
            userId, model.PhoneNumber, model.Code);

             if (result.Succeeded)
             {
            var user = _userManager.FindById(userId);

            if (user != null)
            {
               SignIn(user, false);
               RedirectToManager(ManageMessageId.AddPhoneSuccess);
            }
             }
             else
             {
            context.ModelState.AddModelError("", "Invalid verification code");
             }
        }
开发者ID:unclebuddhabelly,项目名称:NavigationIdentity2,代码行数:25,代码来源:AccountController.cs


示例9: VerifyPhoneNumber

        public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            //The ChangePhoneNumberAsync method checks the posted security code. 
            //If the code is correct, the phone number is added to the PhoneNumber field of the AspNetUsers table. 
            var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code);

            //If that call is successful, the  SignInAsync method is called:
            if (result.Succeeded)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                if (user != null)
                {

                     //The isPersistent parameter sets whether the authentication session is persisted across multiple requests.

                    //When you change your security profile, a new security stamp is generated and stored in the SecurityStamp field of the AspNetUsers table. 
                    //Note, the SecurityStamp field is different from the security cookie. 
                    //The security cookie is not stored in the AspNetUsers table (or anywhere else in the Identity DB). 
                    //The security cookie token is self-signed using DPAPI and is created with the UserId, SecurityStamp and expiration time information.

                    //The cookie middleware checks the cookie on each request. 
                    //The SecurityStampValidator method in the Startup class hits the DB and checks security stamp periodically, as specified with the validateInterval. 
                    //This only happens every 30 minutes (in our sample) unless you change your security profile. //
                    //The 30 minute interval was chosen to minimize trips to the database. 

                    //The SignInAsync method needs to be called when any change is made to the security profile. 
                    //When the security profile changes, the database is updates the SecurityStamp field, and without calling the SignInAsync 
                    //method you would stay logged in only until the next time the OWIN pipeline hits the database (the validateInterval). 
                    //You can test this by changing the SignInAsync method to return immediately, and setting the cookie validateInterval 
                    //property from 30 minutes to 5 seconds:

                    //private async Task SignInAsync(ApplicationUser user, bool isPersistent)
                    //{
                    //    // Clear the temporary cookies used for external and two factor sign ins
                    //    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie,
                    //       DefaultAuthenticationTypes.TwoFactorCookie);
                    //    AuthenticationManager.SignIn(new AuthenticationProperties
                    //    {
                    //        IsPersistent = isPersistent
                    //    },
                    //       await user.GenerateUserIdentityAsync(UserManager));
                    //}

                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                }
                return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
            }
            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "Failed to verify phone");
            return View(model);
        }
开发者ID:alikuli,项目名称:Bearer,代码行数:55,代码来源:ManageController.cs



注:本文中的VerifyPhoneNumberViewModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Version类代码示例发布时间:2022-05-24
下一篇:
C# VerifyCodeViewModel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap