public UserSession Logout([FromBody] LogoutModel logout)
        {
            ;
            // get user based on email and password
            if (logout.SessionKey.Length <= 0)
            {
                return(new UserSession()
                {
                    Success = false,
                    Message = "Invalid Session Key",
                    SessionKey = ""
                });
            }

            _connection.Open();

            SqlCommand update_command = new SqlCommand("UPDATE [dbo].[user] SET [session_key] = '' WHERE [session_key] like @session_key", _connection);

            update_command.Parameters.AddWithValue("@session_key", logout.SessionKey);
            update_command.CommandType = CommandType.Text;
            update_command.ExecuteNonQuery();

            _connection.Close();

            return(new UserSession()
            {
                Success = true,
                Message = "User logged out succesfully",
                SessionKey = ""
            });
        }
        /// <summary>
        /// Create the page under test
        /// </summary>
        /// <returns>The page</returns>
        private LogoutModel CreatePage()
        {
            mockUserContext = new Mock <IApplicationUserContext>();
            var page = new LogoutModel(mockUserContext.Object, new Mock <ILogger <LogoutModel> >().Object);

            return(page);
        }
        private async Task <LogoutModel> BuildLogoutViewModelAsync(string logoutId)
        {
            var model = new LogoutModel {
                LogoutId = logoutId, ShowLogoutPrompt = AccountOptions.ShowLogoutPrompt
            };

            var user = this.HttpContext.User;

            if (user?.Identity.IsAuthenticated != true)
            {
                // if the user is not authenticated, then just show logged out page
                model.ShowLogoutPrompt = false;
                return(model);
            }

            var context = await this.interaction.GetLogoutContextAsync(logoutId);

            if (context?.ShowSignoutPrompt == false)
            {
                // it's safe to automatically sign-out
                model.ShowLogoutPrompt = false;
                return(model);
            }

            // show the logout prompt. this prevents attacks where the user
            // is automatically signed out by another malicious web page.
            return(model);
        }
Beispiel #4
0
        public IActionResult Logout([FromForm] LogoutModel model)
        {
            var loginKey = _db.CajLogin.FirstOrDefault(x => x.Key == model.Token);

            _db.CajLogin.Remove(loginKey);
            _db.SaveChanges();
            return(Ok());
        }
Beispiel #5
0
        private void Logout()
        {
            var model = new LogoutModel();

            model.LogoutCompleted += LogoutCompleted;

            model.Logout();
        }
Beispiel #6
0
        public async Task <IActionResult> Logout(string logoutId)
        {
            var model = new LogoutModel {
                LogoutId = logoutId
            };

            return(await Logout(model));
        }
Beispiel #7
0
        public async Task <IActionResult> Logout(LogoutModel model)
        {
            var vm = await _viewSvc.GetLoggedOutView(model.LogoutId);

            await HttpContext.SignOutAsync();

            _cookies.Remove(NOTICE_COOKIE);

            return(View("LoggedOut", vm));
        }
        public ActionResult Logout(LogoutModel model)
        {
            var logout = model.logout();

            if (logout.Count == 0)
            {
                return(RedirectToAction("Login", "Account"));
            }
            return(RedirectToAction("index", "User"));
        }
Beispiel #9
0
        public async Task LogOut()
        {
            progress = new ProgressDialog(this);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Horizontal);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            progress.Show();

            logout_data = new LogoutModel();
            logout_data.LoginIdentity = identity;
            string logout_json = JsonConvert.SerializeObject(logout_data);

            try
            {
                logout = await restService.LogoutUser(this, location, version, logout_json).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
            }

            if (logout.Equals("Ok"))
            {
                ISharedPreferencesEditor editor = prefs.Edit();
                editor.Remove("OrganizationId");
                editor.Remove("Organization");
                editor.Remove("OfficeId");
                editor.Remove("OfficeName");
                editor.Remove("NaturalPersonId");
                editor.Remove("UserName");
                editor.Remove("NpToOrgRelationID");
                editor.Remove("DesignationId");
                editor.Remove("Designation");
                editor.Remove("MobileNumber");
                editor.Remove("NPPhoto");
                editor.Remove("EmailAddress");
                editor.Remove("LoginIdentity");
                editor.Remove("IsRegistered");
                editor.Remove("GoogleLogin");
                editor.Remove("username1");
                editor.Remove("mobile");
                editor.Remove("mobile12");
                editor.Remove("username12");
                editor.Remove("Location");
                editor.Commit();

                db.deleteTables();

                //((ActivityManager)Application.Context.GetSystemService(ActivityService)).ClearApplicationUserData();
                Intent intent = new Intent(this, typeof(LoginMain_Activity));

                StartActivity(intent);
                Finish();
            }
        }
Beispiel #10
0
        public async Task <IActionResult> Logout(LogoutModel model)
        {
            var context = await _interactionService.GetLogoutContextAsync(model.LogoutId);

            model.PostLogoutRedirectUri = context?.PostLogoutRedirectUri;
            if (User?.Identity.IsAuthenticated == true)
            {
                await HttpContext.SignOutAsync();
            }
            return(View(model));
        }
Beispiel #11
0
            public string BindLogoutRequest(string username, string sessionId)
            {
                AccountSettings accountSettings = new AccountSettings();
                LogoutModel     model           = new LogoutModel();

                model.NameId         = username;
                model.SessionIndex   = sessionId;
                model.Issuer         = accountSettings.sloIssuerUrl;
                model.DestinationUrl = new Uri(accountSettings.idp_slo_url);
                return(Saml2Binding.Get(Saml2BindingType.HttpRedirect)
                       .Bind(model.ToLogoutRequest()).Location.OriginalString);
            }
        public async Task SignOutAsync(LogoutModel logoutModel)
        {
            // In fact, we just add a signout date for auditing
            // Because JWT is helping us to validate service-self instead of connecting back to Identity Server
            // For micro-services, we need to implement distributed JWT cache for signing out all sessions

            var userSession = await _userSessionRepository.GetOneAsync(logoutModel.UserSession);

            userSession.SignOutDate    = DateTime.UtcNow;
            userSession.AlreadySignOut = true;
            await _userSessionRepository.UpdateAsync(userSession.Id, userSession);
        }
Beispiel #13
0
 public ActionResult Logout(LogoutModel model)
 {
     _authManager.Forget(Response);
     if (string.IsNullOrEmpty(model.BackUrl))
     {
         return(RedirectToAction("Index", "Themes"));
     }
     else
     {
         return(Redirect(model.BackUrl));
     }
 }
 public IHttpActionResult Logout([FromBody] LogoutModel logoutModel)
 {
     if (!LoggedUsers.Contains(logoutModel.Username))
     {
         return(BadRequest($"User '{logoutModel.Username}' was not logged in."));
     }
     else
     {
         LoggedUsers.Remove(logoutModel.Username);
         return(Ok());
     }
 }
Beispiel #15
0
 private void Logout(LogoutModel logoutModel)
 {
     layoutProgress.Visibility = ViewStates.Visible;
     Log.Debug(TAG, "Local Logout Started");
     PreferenceHandler.setLoggedIn(false);
     PreferenceHandler.SetToken(string.Empty);
     PreferenceHandler.SetRefreshToken(string.Empty);
     PreferenceHandler.SaveUserDetails(new UserDetails());
     CookieManager.Instance.RemoveAllCookie();
     StartActivity(new Intent(Application.Context, typeof(LoginActivity)));
     Finish();
     layoutProgress.Visibility = ViewStates.Gone;
 }
        public void LogOutFunctionsProperly()
        {
            MockStoreContexts mock = new MockStoreContexts();
            LogoutModel       lm   = new LogoutModel(mock.SignInManager.Object);

            mock.SignInManager.Setup(x => x.SignOutAsync())
            .Returns(Task.CompletedTask);

            var result = lm.OnGet().Result;
            RedirectToPageResult check = (RedirectToPageResult)result;

            Assert.Equal("/", check.PageName);
        }
Beispiel #17
0
        public ActionResult LogoutAction()
        {
            LogoutModel m = new LogoutModel();

            m.email = Session["email"] as string;

            string response = postData(JsonConvert.SerializeObject(m),
                                       "http://localhost:9001/BookEditorServices/auth/logout");

            Session.Clear();

            return(PartialView("_Login"));
        }
        public async Task <IActionResult> Logout(LogoutModel model)
        {
            var context = await _interactionService.GetLogoutContextAsync(model.LogoutId);

            model.PostLogoutRedirectUri = context?.PostLogoutRedirectUri;
            if (User?.Identity.IsAuthenticated == true)
            {
                await _signInManager.SignOutAsync();

                await _eventService.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
            }
            return(View(model));
        }
Beispiel #19
0
        public async Task <IActionResult> Logout(LogoutModel model, string returnUrl = null)
        {
            await _signInManager.SignOutAsync();

            _logger.LogInformation("User logged out.");
            if (returnUrl != null)
            {
                return(LocalRedirect(returnUrl));
            }
            else
            {
                return(View(model));
            }
        }
        public IHttpActionResult Logout([FromBody] LogoutModel model)
        {
            String status      = "200";
            String description = "Response Okay";

            //operation
            UserDoa doa = new UserDoa();
            Tuple <String, String> data = doa.deleteAccessToken(model.userid, model.deviceid);

            status      = data.Item1;
            description = data.Item2;


            return(Ok(new { status, description }));
        }
        public async Task <IActionResult> Logout(string logoutId)
        {
            var model = new LogoutModel {
                LogoutId = logoutId
            };

            if (!await ShouldShowLogoutAsync(logoutId))
            {
                return(await Logout(model));
            }
            else
            {
                return(View(nameof(Logout), model));
            }
        }
Beispiel #22
0
        public void Setup()
        {
            _signInManagerMock = new Mock <ISupportAppSignInManager>(MockBehavior.Strict);
            _user = new ClaimsPrincipal();

            _sut = new LogoutModel(_signInManagerMock.Object, Mock.Of <ILogger <LogoutModel> >())
            {
                PageContext = new PageContext
                {
                    HttpContext = new DefaultHttpContext
                    {
                        User = _user,
                    },
                }
            };
        }
Beispiel #23
0
        public HttpStatusCode Logout(LogoutModel logoutModel)
        {
            var url    = string.Format("{0}/api/Account/Logout", _baseUrl);
            var client = new RestClient(
                new RequestHeader("Email", logoutModel.Email),
                new RequestHeader("Token", logoutModel.Token));

            try
            {
                var response = client.Post(url, string.Empty);
                return(response.StatusCode);
            }
            catch (UnexpectedStatusException ex)
            {
                return((HttpStatusCode)ex.StatusCode);
            }
        }
        public IHttpActionResult Logout(LogoutModel model)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(GetModelStateErrors(ModelState));
            //}

            //var channelType = GetChannelType();

            //var apiResp = LogoutUser(model.DeviceKey, channelType);

            //if (apiResp.ResponseCode != ResponseCode.Success)
            //{
            //    return BadRequest(apiResp.ResponseMessage);
            //}

            //return Ok(apiResp);
            return(Ok());
        }
Beispiel #25
0
 private void Logout(LogoutModel logoutModel)
 {
     Log.Debug(TAG, "Local Logout Successful");
     //PreferenceHandler preferenceHandler = new PreferenceHandler();
     PreferenceHandler.setLoggedIn(false);
     layoutProgress.Visibility = ViewStates.Gone;
     Finish();
     StartActivity(new Intent(Application.Context, typeof(LoginNewActivity)));
     //Log.Debug(TAG, "Logout() " + logoutModel.ToString());
     //var response = await InvokeApi.Invoke(Constants.API_SIGN_OUT, JsonConvert.SerializeObject(logoutModel), HttpMethod.Post);
     //if (response.StatusCode != 0)
     //{
     //    Log.Debug(TAG, "async Response : " + response.ToString());
     //    RunOnUiThread(() =>
     //    {
     //        LogoutResponse(response);
     //    });
     //}
 }
        async void _logOut()
        {
            var answer = await App.Current.MainPage.DisplayAlert(AppResource.Logout,
                                                                 AppResource.LogoutMsg, AppResource.Yes, AppResource.No);

            if (answer)
            {
                try
                {
                    if ((Connectivity.ConnectionProfiles.Contains(ConnectionProfile.WiFi) && Connectivity.NetworkAccess.Equals(NetworkAccess.Internet)) || (Connectivity.ConnectionProfiles.Contains(ConnectionProfile.Cellular) && Connectivity.NetworkAccess.Equals(NetworkAccess.Internet)))
                    {  //await _navigation.PushPopupAsync(new LoaderPopup());
                        UserDialogs.Instance.ShowLoading("");
                        var requestModel = new LogoutModel()
                        {
                            UserId = CurrentUserId
                        };

                        LogoutResponseModel response;
                        try
                        {
                            response = await webApiRestClient.PostAsync <LogoutModel, LogoutResponseModel>(ApiHelpers.Logout, requestModel);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("LogoutApi_Exception:- " + ex.Message);
                            response = null;
                        }
                        if (response != null)
                        {
                            if (response.status)
                            {
                                //App.Database.ClearLoginDetails();
                                if (Application.Current.Properties.ContainsKey("CurrentUserId"))
                                {
                                    Application.Current.Properties.Remove("CurrentUserId");;
                                    await Application.Current.SavePropertiesAsync();
                                }
                                CurrentUserId = 0;
                                if (userDataDbService.IsUserDbPresentInDB())
                                {
                                    var       data = userDataDbService.ReadAllItems().FirstOrDefault();
                                    BsonValue id   = data.ID;
                                    userDataDbService.DeleteItemFromDB(id, data);
                                }

                                App.Current.MainPage = new NavigationPage(new LoginPage());
                            }
                            else
                            {
                                await MaterialDialog.Instance.SnackbarAsync(message : response.message,
                                                                            msDuration : MaterialSnackbar.DurationShort);
                            }
                        }
                        else
                        {
                            await MaterialDialog.Instance.SnackbarAsync(message : AppResource.ServerError,
                                                                        msDuration : MaterialSnackbar.DurationShort);
                        }
                        UserDialogs.Instance.HideLoading();
                    }
                    else
                    {
                        await MaterialDialog.Instance.SnackbarAsync(message : AppResource.NoInternetError,
                                                                    msDuration : MaterialSnackbar.DurationShort);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("LoginCommand_Exception:- " + ex.Message);
                    UserDialogs.Instance.HideLoading();
                }
                finally
                {
                    //await _navigation.PopAllPopupAsync(true);
                }
            }
            //if (answer)
            //{
            //    if (Application.Current.Properties.ContainsKey("CurrentUserId"))
            //    {
            //        Application.Current.Properties.Remove("CurrentUserId"); ;
            //        await Application.Current.SavePropertiesAsync();
            //    }
            //    CurrentUserId = 0;
            //    if (userDataDbService.IsUserDbPresentInDB())
            //    {
            //        var data = userDataDbService.ReadAllItems().FirstOrDefault();
            //        BsonValue id = data.ID;
            //        userDataDbService.DeleteItemFromDB(id, data);
            //    }

            //    App.Current.MainPage = new NavigationPage(new LoginPage());
            //}
        }
Beispiel #27
0
        public async Task <IActionResult> Logout([FromBody] LogoutModel logoutModel)
        {
            await _identityServiceProvider.SignOutAsync(logoutModel);

            return(Ok());
        }
Beispiel #28
0
 public override async Task <UserModel> Logout(LogoutModel request, ServerCallContext context)
 {
     return(null);
 }
Beispiel #29
0
        public async Task <IActionResult> Logout(LogoutModel model)
        {
            await HttpContext.SignOutAsync();

            return(Redirect(model?.ReturnUrl ?? "~/"));
        }
Beispiel #30
0
 public Response <bool> Logout([FromBody] LogoutModel model)
 {
     _chche.Remove(model.Token);
     return(true);
 }
 public void ExecuteLogout(LogoutModel request)
 {
     _secureSession.Logout();
 }