示例#1
0
        public async Task <IActionResult> RemoveLogin(IEnumerable <RemoveLoginViewModel> account, string RemoveButton)
        {
            var user = await _userManager.FindByIdAsync(_userManager.GetUserId(User));

            var loginProvider = RemoveButton.Split(':')[0];
            var providerKey   = RemoveButton.Split(':')[1];

            var result = await _userManager.RemoveLoginAsync(user, loginProvider, providerKey);

            var message = string.Empty;

            if (result.Succeeded)
            {
                await _signInManager.SignInAsync(user, isPersistent : false);

                _userEngine.ClearUserSession(_userManager.GetUserId(User));
                _notificationService.AddNotification(user.Id, NotificationTypes.UnLinkExternalProvider, param: loginProvider);

                return(RedirectToRoute("settings"));
            }
            else
            {
                TempData["message"]        = string.Join(";", result.Errors.Select(i => i.Description));;
                TempData["messagesuccess"] = false;
            }

            TempData["message"]        = "Beklenmedik bir hata oluştu. Lütfen tekrar deneyiniz.";
            TempData["messagesuccess"] = false;
            return(RedirectToRoute("settings"));
        }