public async Task <IActionResult> Logout(LogoutInputModel model) { var signOutUser = new SignOutUserBasedOnProvider(model.LogoutId); // We perform the use log out flow and return the view model var vm = await _mediator.Send(signOutUser); // Return a Javascript View that registers an i-frame with the postLogoutUrl. The view returns in an blink of an eye for better UX return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId); await _signInManager.SignOutAsync(); _logger.LogInformation("User logged out."); return(Redirect(vm.PostLogoutRedirectUri)); }
public async Task <IActionResult> OnPost(LogoutInputModel model) { var viewModel = await BuildLoggedOutViewModelAsync(model.LogoutId); if (User.Identity.IsAuthenticated) { await _signInManager.SignOutAsync(); } return(Redirect(viewModel.PostLogoutRedirectUri)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId); // delete local authentication cookie await HttpContext.Authentication.SignOutAsync(); await HttpContext.Authentication.SignOutAsync("Cookies"); return(View("LoggedOut", vm)); }
public IActionResult Logout(string logoutId) { if (User?.Identity?.IsAuthenticated != true) { return(View("LoggedOut", new LogoutDto())); } var vm = new LogoutInputModel { LogoutId = logoutId }; return(View(vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { // build a model so the logged out page knows what to display var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); if (User?.Identity.IsAuthenticated == true) { // delete local authentication cookie await _signInManager.SignOutAsync(); } return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model, CancellationToken cancellationToken) { var response = await _mediator.Send(new Logout.Command { ControllerContext = HttpContext, HttpResponse = Response, LogoutId = model.LogoutId, User = User }, cancellationToken); if (response.Result) { return(Ok(response)); } return(BadRequest(response)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { // get context information (client name, post logout redirect URI and iframe for federated signout) var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId); if (User?.Identity.IsAuthenticated == true) { await _signInManager.SignOutAsync(); // raise the logout event await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); } return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { // build a model so the logged out page knows what to display var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); if (User?.Identity.IsAuthenticated == true) { // delete local authentication cookie await HttpContext.SignOutAsync(); // raise the logout event await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); } return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { // Получаем модель для экрана успешного выхода пользователя, чтобы знать что показать пользователю. var viewModel = await _accountService.BuildLoggedOutViewModelAsync(model.LogoutId); if (User?.Identity.IsAuthenticated == true) { // Удаляем аутентификационную куку await HttpContext.SignOutAsync(); // Эммитим событие о выходе пользователя await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); } return(View("LoggedOut", viewModel)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); var user = HttpContext.User; if (user?.Identity.IsAuthenticated == true) { await HttpContext.SignOutAsync(); await _signInManager.SignOutAsync(); await _events.RaiseAsync(new UserLogoutSuccessEvent(user.GetSubjectId(), user.GetDisplayName())); } return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout([FromForm] LogoutInputModel inputModel) { var viewModel = await BuildLoggedOutViewModelAsync(inputModel.LogoutId); await _signInManager.SignOutAsync(); if (viewModel.ExternalLoginProvider != null) { var url = Url.RouteUrl("Logout", new { logoutId = viewModel.LogoutId }); return(SignOut(new AuthenticationProperties { RedirectUri = url }, viewModel.ExternalLoginProvider)); } return(View("LoggedOut", viewModel)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId); await _signInManager.SignOutAsync(); _logger.LogInformation("User logged out."); if (vm.TriggerExternalSignout) { string url = Url.Action("Logout", new { logoutId = vm.LogoutId }); return(SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme)); } return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); if (User?.Identity.IsAuthenticated == true) { await _signInManager.SignOutAsync(); await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); } if (vm.TriggerExternalSignout) { var url = Url.Action("Logout", new { logoutId = vm.LogoutId }); return(SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme)); } return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { if (User.Identity?.IsAuthenticated != true) { return(Redirect("~/")); } // delete local authentication cookie await _signInManager.SignOutAsync(); // Returning a SignOutResult will ask OpenIddict to redirect the user agent // to the post_logout_redirect_uri specified by the client application or to // the RedirectUri specified in the authentication properties if none was set. return(SignOut( authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, properties: new AuthenticationProperties { RedirectUri = "/login" })); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId); if (model is LogoutViewModel) { vm.PostLogoutRedirectUri = (model as LogoutViewModel).PostLogoutRedirectUrl; } if (vm.TriggerExternalSignout) { var url = Url.Action("Logout", new { logoutId = vm.LogoutId }); await HttpContext.Authentication.SignOutAsync(vm.ExternalAuthenticationScheme, new AuthenticationProperties { RedirectUri = url }); } await HttpContext.Authentication.SignOutAsync(); return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { // build a model so the logged out page knows what to display // Ovdje je ViewModel za You have been successfully logged out // Ja mislim da sam ja ovdje odma puko da vrate na pocetnu nasu, bukvalno se na 1 sekundu vidi taj view var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); //User.Identity.IsAuthenticated nema veze ni sa Identityem, ni IS4 //ova funkcija iz System namespace i kaze da li je korisnik autentifikovan if (User?.Identity.IsAuthenticated == true) { // delete local authentication cookie // brise microsoft identity cookie await _signInManager.SignOutAsync(); // raise the logout event // brise identity server 4 token await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); } // check if we need to trigger sign-out at an upstream identity provider // ovo je lupam ako smo implementirali Google ili Facebook login pa on ga baci na njihove API da se odjave // moze se ovo izbrisat skroz ili zakomentarisat if (vm.TriggerExternalSignout) { // build a return URL so the upstream provider will redirect back // to us after the user has logged out. this allows us to then // complete our single sign-out processing. string url = Url.Action("Logout", new { logoutId = vm.LogoutId }); // this triggers a redirect to the external provider for sign-out return(SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme)); } // Dzaba sto on baca na View Logged Out ako pogledas klasu AccountOptions odma ispod ovog kontrolera // Vidjeces da sam stavio da automatski redirekta nakon log outa return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await this.identityServerService.BuildLoggedOutViewModelAsync(model.LogoutId, this.User, this.HttpContext).ConfigureAwait(false); if (this.User?.Identity.IsAuthenticated == true) { await this.signInManager.SignOutAsync().ConfigureAwait(false); await this.events.RaiseAsync(new UserLogoutSuccessEvent(this.User.GetSubjectId(), this.User.GetDisplayName())).ConfigureAwait(false); } if (vm.TriggerExternalSignout) { var url = this.Url.Action(nameof(this.Logout), new { logoutId = vm.LogoutId }); return(this.SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme)); } return(this.View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { _logger.LogInformation("Logout {User}", User?.Identity?.Name); var vm = new LogoutDto(); var authenticated = User?.Identity?.IsAuthenticated == true; if (authenticated) { if (string.IsNullOrEmpty(model.LogoutId)) { var idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value; if (idp != null && idp != IdentityServer4.IdentityServerConstants.LocalIdentityProvider && await HttpContext.GetSchemeSupportsSignOutAsync(idp)) { model.LogoutId = await _interaction.CreateLogoutContextAsync(); } } vm = await _mediator.Send(new DoLogoutCommand(model.LogoutId, User.GetSubjectId(), User.GetDisplayName())); } return(View("LoggedOut", vm)); }
public async Task<IActionResult> Logout(LogoutInputModel model) { var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId); await _signInManager.SignOutAsync(); _logger.LogInformation("User logged out."); // check if we need to trigger sign-out at an upstream identity provider if (vm.TriggerExternalSignout) { // build a return URL so the upstream provider will redirect back // to us after the user has logged out. this allows us to then // complete our single sign-out processing. string url = Url.Action("Logout", new { logoutId = vm.LogoutId }); // this triggers a redirect to the external provider for sign-out // hack: try/catch to handle social providers that throw return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme); } return View("LoggedOut", vm); }
public async Task <IActionResult> Logout(LogoutInputModel model) { // build a model so the logged out page knows what to display var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); if (User?.Identity.IsAuthenticated == true) { // delete local authentication cookie await _signInManager.SignOutAsync(); // raise the logout event await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); } // check if we need to trigger sign-out at an upstream identity provider if (vm.TriggerExternalSignout) { // build a return URL so the upstream provider will redirect back // to us after the user has logged out. this allows us to then // complete our single sign-out processing. string url = Url.Action("Logout", new { logoutId = vm.LogoutId }); // this triggers a redirect to the external provider for sign-out return(SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme)); } //hongsh if (!string.IsNullOrWhiteSpace(vm.PostLogoutRedirectUri)) { return(Redirect(vm.PostLogoutRedirectUri)); } else { return(View("LoggedOut", vm)); } }
public async Task <IActionResult> Logout(LogoutInputModel model) { if (User?.Identity.IsAuthenticated == true) { var subjectId = HttpContext.User.Identity.GetSubjectId(); // delete local authentication cookie await _signInManager.SignOutAsync(); var logout = await _interaction.GetLogoutContextAsync(model.LogoutId); var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); await _persistedGrantService.RemoveAllGrantsAsync(subjectId, logout?.ClientId); if (!string.IsNullOrEmpty(vm.PostLogoutRedirectUri)) { return(Redirect(vm.PostLogoutRedirectUri)); } } return(RedirectToAction(nameof(HomeController.Index), "Home")); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); if (User?.Identity.IsAuthenticated == true) { await HttpContext.SignOutAsync(); } //// check if we need to trigger sign-out at an upstream identity provider //if (vm.TriggerExternalSignout) //{ // // build a return URL so the upstream provider will redirect back // // to us after the user has logged out. this allows us to then // // complete our single sign-out processing. // string url = Url.Action("Logout", new { logoutId = vm.LogoutId }); // // this triggers a redirect to the external provider for sign-out // return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme); // } return(View("LoggedOut", vm)); }
public async Task <IActionResult> Logout(LogoutInputModel inputModel) { var model = await this.BuildLoggedOutViewModelAsync(inputModel.LogoutId); await this.signInManager.SignOutAsync(); this.logger.LogInformation("User logged out."); // check if we need to trigger sign-out at an upstream identity provider if (model.TriggerExternalSignout) { // build a return URL so the upstream provider will redirect back to us after the user has logged out // this allows us to then complete our single sign-out processing string url = this.Url.Action("Logout", new { logoutId = model.LogoutId }); // this triggers a redirect to the external provider for sign-out hack try/catch to handle social providers that throw return(this.SignOut(new AuthenticationProperties { RedirectUri = url }, model.ExternalAuthenticationScheme)); } return(this.View("LoggedOut", model)); }
public async Task <IActionResult> Logout(LogoutInputModel model) { var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); if (vm.TriggerExternalSignout) { string url = Url.Action("Logout", new { logoutId = vm.LogoutId }); try { // hack: try/catch to handle social providers that throw await HttpContext.SignOutAsync(vm.ExternalAuthenticationScheme, new AuthenticationProperties { RedirectUri = url }); } catch (NotSupportedException nex) // this is for the external providers that don't have signout { _logger.LogError($"Error signing out from external provider for logout id {vm.LogoutId}.", nex); } catch (InvalidOperationException iex) // this is for Windows/Negotiate { _logger.LogError($"Error signing out from external provider for logout id {vm.LogoutId}.", iex); } } if (User?.Identity.IsAuthenticated == true) { // delete local authentication cookie await HttpContext.SignOutAsync(IdentityServerConstants.DefaultCookieAuthenticationScheme); await _signInManager.SignOutAsync(); await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); } HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity()); return(View("LoggedOut", vm)); }
private async Task <LogoutInputModel> BuildLogoutInputModelAsync(string logoutId) { var inputModel = new LogoutInputModel { LogoutId = logoutId, ShowLogoutPrompt = true }; if (!User.Identity.IsAuthenticated) { inputModel.ShowLogoutPrompt = false; return(inputModel); } var context = await _interactionService.GetLogoutContextAsync(logoutId); if (!context.ShowSignoutPrompt) { inputModel.ShowLogoutPrompt = false; return(inputModel); } return(inputModel); }
public async Task <IActionResult> Logout(LogoutInputModel model) { await HttpContext.SignOutAsync(); return(RedirectToAction("LoggedOut")); }
public LogoutViewModel Execute(LogoutInputModel inputModel) { _authenticationContext.SignOut(); return new LogoutViewModel(); }
public LogoutViewModel Execute(LogoutInputModel inputModel) { _authenticationContext.SignOut(); return(new LogoutViewModel()); }
public FubuContinuation Execute(LogoutInputModel input) { authenticationService.Logout(); return FubuContinuation.RedirectTo<Timetable.TimetableRequest>(); }