public static async Task LoginTest() { var methods = new UserMethod(ConnectionApi.HttpClient); await methods.Login("*****@*****.**", "g"); if (methods.User == null) { throw new Exception(); } else { Console.WriteLine(methods.User.EmailAddress, methods.User.Id); } }
public static async Task GetAllNotesTest() { var methods = new NoteMethod(ConnectionApi.HttpClient); var authtoken = new AuthenticationToken(ConnectionApi.HttpClient); var userMethod = new UserMethod(ConnectionApi.HttpClient); await userMethod.Login("*****@*****.**", "ss"); var token = await authtoken.PostAuthRecordAsync(userMethod.Record); IEnumerable <Note> col = await methods.GetAllNotesFromDatabase(token); foreach (var el in col) { Console.WriteLine(el.Id); } }
public async void MakeLoginTask() { try { UserMethod methods = new UserMethod(ConnectionApi.HttpClient); methods.PreparedAuthenticationRecord(); await methods.Login(methods.Record.Email, methods.Record.PasswordHash, true); MultiNotesMainWindow mainWindow = new MultiNotesMainWindow(); mainWindow.Show(); } catch (Exception e) { MultiNotesLoginWindow loginWindow = new MultiNotesLoginWindow(); loginWindow.Show(); } }
public async void Login(string email, string password, bool isPasswordHashed = false) { var methods = new UserMethod(ConnectionApi.HttpClient); try { await methods.Login(email, password, isPasswordHashed); MultiNotesMainWindow mainWindow = new MultiNotesMainWindow(); mainWindow.Show(); _closeAction.Invoke(); } catch (Exception e) { //todo: tak nie moze zostac, tu musi byc sensowna obsluga wyjatkow roznych typow MessageBox.Show("Dupas"); } }
public static void Login() { using (var context = new CarContext()) { UserMethod ob = UserMethod.Login(); try { var seller = context.Sellers.Single(s => s.Name == ob.Name); ob.EnableUser(seller); ob.ShowUser(); } catch (InvalidOperationException) { Console.WriteLine("Шо за хуйню ты ввел??? Нет там такого имени\n"); } } }
public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { // поиск пользователя в бд var UserId = UserMethod.Login(model); if (UserId != null) { FormsAuthentication.SetAuthCookie(UserId.ToString(), true); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Пользователя с таким логином и паролем нет"); } } return(View(model)); }
public static async Task PostNote() { var methods = new NoteMethod(ConnectionApi.HttpClient); var authtoken = new AuthenticationToken(ConnectionApi.HttpClient); var userMethod = new UserMethod(ConnectionApi.HttpClient); await userMethod.Login("*****@*****.**", "ss"); var token = await authtoken.PostAuthRecordAsync(userMethod.Record); var id = await UniqueId.GetUniqueBsonId(ConnectionApi.HttpClient); var Note = new Note() { Content = "test", CreateTimestamp = DateTime.Now, Id = id, LastChangeTimestamp = DateTime.Now, OwnerId = userMethod.User.Id }; methods.AddNoteToDatabase(Note, token); }