private async Task AutoLogin() { var autologin = new Logincredentials().getcredentialfromlocker(1); if (autologin != null) { autologin.RetrievePassword(); //check if user changed the password Logincredentials login = new Logincredentials(); bool canweusethepassword = await login.logincredential(autologin.UserName, autologin.Password, 1); switch (canweusethepassword) { case true: await DataProvider.GrabUserDatatoOffline(1); _navigationService.NavigateTo("HomePage"); _Fnavigationservice.NavigateTo("VirDir"); break; case false: break; } } }
private async void Logout_test(object sender, RoutedEventArgs e) { MessageDialog popup = new MessageDialog("Do you want to log out from this account?", "Logout"); popup.Commands.Add(new UICommand("Logout") { Id = 0 }); popup.Commands.Add(new UICommand("Cancel") { Id = 1 }); popup.DefaultCommandIndex = 0; popup.CancelCommandIndex = 1; var result = await popup.ShowAsync(); if ((int)result.Id == 0) { //remove user credentials var getuserpass = new Logincredentials().getcredentialfromlocker(1); getuserpass.RetrievePassword(); var vault = new Windows.Security.Credentials.PasswordVault(); vault.Remove(new Windows.Security.Credentials.PasswordCredential(getuserpass.Resource, getuserpass.UserName, getuserpass.Password)); //navigate back to the loginpage f.Navigate(typeof(LoginPage)); Window.Current.Content = f; Window.Current.Activate(); } }
public IHttpActionResult PostAdminLogin(Logincredentials cred) { adminMaster temp = db.adminMasters.Where(x => x.admin_username == cred.user_name && x.admin_password == cred.user_password).FirstOrDefault(); if (temp == null) { return(Ok(0)); } return(Ok(1)); }
public IHttpActionResult PostUserLogin(Logincredentials cred) { Customer temp = db.Customers.Where(x => x.user_name == cred.user_name && x.user_password == cred.user_password).FirstOrDefault(); if (temp == null) { return(Ok(0)); } return(Ok(1)); }
/* private async void result(object sender, RoutedEventArgs e) * { * try * { * var getlogincredentials = new GrabUserList().getcredentialfromlocker(); * getlogincredentials.RetrievePassword(); * var url = new Uri("http://myanimelist.net/api/account/verify_credentials.xml"); * //string storeusercredential_myanimelist = "mall"; * GrabUserList nn = new GrabUserList(); * * var clientHeader = new HttpBaseProtocolFilter(); * clientHeader.ServerCredential = new PasswordCredential(getlogincredentials.Resource,getlogincredentials.UserName, getlogincredentials.Password); * clientHeader.AllowUI = false; * using (var client = new HttpClient(clientHeader)) * { * HttpResponseMessage response = await client.GetAsync(url); * response.EnsureSuccessStatusCode(); * string getrespond = await response.Content.ReadAsStringAsync(); * //store password * //var vault = new PasswordVault(); * //var cred = clientHeader.ServerCredential; * //vault.Add(cred); * test.Content = getrespond; * } #region oldcode_but_works * // old one, but works * // problem : can't disable basic authentication pop-up when failed to login. * /*using (HttpClient client = new HttpClient()) { * //client.DefaultRequestHeaders.Accept.TryParseAdd("application/json"); * client.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("basic",Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", username, password)))); * using (HttpResponseMessage response = await client.GetAsync(url)) * { * response.EnsureSuccessStatusCode(); * string getresponse = await response.Content.ReadAsStringAsync(); * test.Content = getresponse; * } * } * #endregion * } * catch (Exception ex) { * test.Content = "Maa-kun confused. She can't use your username / password to access it :("; * } * }*/ private async void SignIn_Click(ContentDialog sender, ContentDialogButtonClickEventArgs e) { Logincredentials login = new Logincredentials(); bool verify = await login.logincredential(usrnm.Text, psswd.Password, 1); switch (verify) { case true: await DataProvider.GrabUserDatatoOffline(1); Navigate(); break; case false: break; } }
public IHttpActionResult PostAdminLogin(Logincredentials cred) { LoginResponseModel1 loginres = new LoginResponseModel1(); adminMaster temp = db.adminMasters.Where(x => x.admin_username == cred.user_name && x.admin_password == cred.user_password).FirstOrDefault(); if (temp == null) { loginres.StatusCode = 0; loginres.Message = "Invalid Login"; loginres.Admin_username = null; return(Ok(loginres)); } else { loginres.StatusCode = 1; loginres.Message = "Login Successful"; loginres.Admin_username = temp.admin_username; return(Ok(loginres)); } }
public IHttpActionResult PostUserLogin(Logincredentials cred) { LoginResponseModel loginres = new LoginResponseModel(); Customer temp = db.Customers.Where(x => x.user_name == cred.user_name && x.user_password == cred.user_password).FirstOrDefault(); if (temp == null) { loginres.StatusCode = 0; loginres.Message = "Invalid Login"; loginres.CustomerId = 0; return(Ok(loginres)); } else { loginres.StatusCode = 1; loginres.Message = "Login Successful"; loginres.CustomerId = temp.customer_id; return(Ok(loginres)); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is string && e.Parameter.ToString() == "usr_ava") { var autologin = new Logincredentials().getcredentialfromlocker(1); autologin.RetrievePassword(); Logincredentials login = new Logincredentials(); bool canweusethepassword = await login.logincredential(autologin.UserName, autologin.Password, 1); switch (canweusethepassword) { case true: await DataProvider.GrabUserDatatoOffline(1); Navigate(); break; case false: break; } } }
protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { DebugSettings.EnableFrameRateCounter = false; } #endif Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } var autologin = new Logincredentials().getcredentialfromlocker(1); string status = null; if (autologin != null) { status = "usr_ava"; } else { status = ""; } rootFrame.Navigate(typeof(LoginPage), status); //rootFrame.Navigate(typeof(SettingsPage)); ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(685, 600)); Window.Current.Activate(); }