Пример #1
0
        public async Task <ActionResult> ExternalLoginConfirmation(
            ExternalLoginConfirmationViewModel model,
            string returnUrl)
        {
            if (this.get_User().Identity.IsAuthenticated)
            {
                return((ActionResult)this.RedirectToAction("Index", "Manage"));
            }
            if (this.get_ModelState().get_IsValid())
            {
                ExternalLoginInfo info = await AuthenticationManagerExtensions.GetExternalLoginInfoAsync(this.AuthenticationManager);

                if (info == null)
                {
                    return((ActionResult)this.View("ExternalLoginFailure"));
                }
                ApplicationUser applicationUser = new ApplicationUser();
                ((IdentityUser <string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>)applicationUser).set_UserName(model.Email);
                ((IdentityUser <string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>)applicationUser).set_Email(model.Email);
                ApplicationUser user   = applicationUser;
                IdentityResult  result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).CreateAsync(user);
                if (result.get_Succeeded())
                {
                    result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).AddLoginAsync(((IdentityUser <string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>)user).get_Id(), info.get_Login());
                    if (result.get_Succeeded())
                    {
                        await this.SignInManager.SignInAsync(user, false, false);

                        return(this.RedirectToLocal(returnUrl));
                    }
                }
                this.AddErrors(result);
                info   = (ExternalLoginInfo)null;
                user   = (ApplicationUser)null;
                result = (IdentityResult)null;
            }
            // ISSUE: reference to a compiler-generated field
            if (AccountController.\u003C\u003Eo__27.\u003C\u003Ep__0 == null)
            {
                // ISSUE: reference to a compiler-generated field
                AccountController.\u003C\u003Eo__27.\u003C\u003Ep__0 = CallSite <Func <CallSite, object, string, object> > .Create(Binder.SetMember(CSharpBinderFlags.None, "ReturnUrl", typeof(AccountController), (IEnumerable <CSharpArgumentInfo>) new CSharpArgumentInfo[2]
                {
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, (string)null),
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, (string)null)
                }));
            }
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            object obj = AccountController.\u003C\u003Eo__27.\u003C\u003Ep__0.Target((CallSite)AccountController.\u003C\u003Eo__27.\u003C\u003Ep__0, ((ControllerBase)this).get_ViewBag(), returnUrl);

            return((ActionResult)this.View((object)model));
        }
Пример #2
0
        public async Task <ActionResult> RemoveLogin(
            string loginProvider,
            string providerKey)
        {
            IdentityResult result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).RemoveLoginAsync(IdentityExtensions.GetUserId(this.get_User().Identity), new UserLoginInfo(loginProvider, providerKey));

            ManageController.ManageMessageId?message;
            if (result.get_Succeeded())
            {
                ApplicationUser user = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).FindByIdAsync(IdentityExtensions.GetUserId(this.get_User().Identity));
                if (user != null)
                {
                    await this.SignInManager.SignInAsync(user, false, false);
                }
                message = new ManageController.ManageMessageId?(ManageController.ManageMessageId.RemoveLoginSuccess);
                user    = (ApplicationUser)null;
            }
            else
            {
                message = new ManageController.ManageMessageId?(ManageController.ManageMessageId.Error);
            }
            return((ActionResult)this.RedirectToAction("ManageLogins", (object)new
            {
                Message = message
            }));
        }
Пример #3
0
        public async Task <ActionResult> ConfirmEmail(string userId, string code)
        {
            if (userId == null || code == null)
            {
                return((ActionResult)this.View("Error"));
            }
            IdentityResult result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).ConfirmEmailAsync(userId, code);

            return((ActionResult)this.View(result.get_Succeeded() ? nameof(ConfirmEmail) : "Error"));
        }
Пример #4
0
        public async Task <ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (!this.get_ModelState().get_IsValid())
            {
                return((ActionResult)this.View((object)model));
            }
            ApplicationUser user = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).FindByNameAsync(model.Email);

            if (user == null)
            {
                return((ActionResult)this.RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            IdentityResult result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).ResetPasswordAsync(((IdentityUser <string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>)user).get_Id(), model.Code, model.Password);

            if (result.get_Succeeded())
            {
                return((ActionResult)this.RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            this.AddErrors(result);
            return((ActionResult)this.View());
        }
Пример #5
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (this.get_ModelState().get_IsValid())
            {
                ApplicationUser applicationUser = new ApplicationUser();
                ((IdentityUser <string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>)applicationUser).set_UserName(model.Email);
                ((IdentityUser <string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>)applicationUser).set_Email(model.Email);
                ApplicationUser user   = applicationUser;
                IdentityResult  result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).CreateAsync(user, model.Password);
                if (result.get_Succeeded())
                {
                    await this.SignInManager.SignInAsync(user, false, false);

                    return((ActionResult)this.RedirectToAction("Index", "Home"));
                }
                this.AddErrors(result);
                user   = (ApplicationUser)null;
                result = (IdentityResult)null;
            }
            return((ActionResult)this.View((object)model));
        }
Пример #6
0
 public async Task <ActionResult> SetPassword(SetPasswordViewModel model)
 {
     if (this.get_ModelState().get_IsValid())
     {
         IdentityResult result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).AddPasswordAsync(IdentityExtensions.GetUserId(this.get_User().Identity), model.NewPassword);
         if (result.get_Succeeded())
         {
             ApplicationUser user = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).FindByIdAsync(IdentityExtensions.GetUserId(this.get_User().Identity));
             if (user != null)
             {
                 await this.SignInManager.SignInAsync(user, false, false);
             }
             return((ActionResult)this.RedirectToAction("Index", (object)new
             {
                 Message = ManageController.ManageMessageId.SetPasswordSuccess
             }));
         }
         this.AddErrors(result);
         result = (IdentityResult)null;
     }
     return((ActionResult)this.View((object)model));
 }
Пример #7
0
        public async Task <ActionResult> RemovePhoneNumber()
        {
            IdentityResult result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).SetPhoneNumberAsync(IdentityExtensions.GetUserId(this.get_User().Identity), (string)null);

            if (!result.get_Succeeded())
            {
                return((ActionResult)this.RedirectToAction("Index", (object)new
                {
                    Message = ManageController.ManageMessageId.Error
                }));
            }
            ApplicationUser user = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).FindByIdAsync(IdentityExtensions.GetUserId(this.get_User().Identity));

            if (user != null)
            {
                await this.SignInManager.SignInAsync(user, false, false);
            }
            return((ActionResult)this.RedirectToAction("Index", (object)new
            {
                Message = ManageController.ManageMessageId.RemovePhoneSuccess
            }));
        }
Пример #8
0
        public async Task <ActionResult> VerifyPhoneNumber(
            VerifyPhoneNumberViewModel model)
        {
            if (!this.get_ModelState().get_IsValid())
            {
                return((ActionResult)this.View((object)model));
            }
            IdentityResult result = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).ChangePhoneNumberAsync(IdentityExtensions.GetUserId(this.get_User().Identity), model.PhoneNumber, model.Code);

            if (result.get_Succeeded())
            {
                ApplicationUser user = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).FindByIdAsync(IdentityExtensions.GetUserId(this.get_User().Identity));
                if (user != null)
                {
                    await this.SignInManager.SignInAsync(user, false, false);
                }
                return((ActionResult)this.RedirectToAction("Index", (object)new
                {
                    Message = ManageController.ManageMessageId.AddPhoneSuccess
                }));
            }
            this.get_ModelState().AddModelError("", "Failed to verify phone");
            return((ActionResult)this.View((object)model));
        }