private static void RegisterUser() { do { success = true; C.Write("Username:\t"); string userName = C.Read(); C.Write("Password:\t"); string password = C.ReadPassword(); stopwatch.Restart(); //AccessToken data = C.CallService<AccessToken, object>(Method.POST, Url.Login, login, HttpHeaders.FormUrlEncoded, false).Result; string registerData = C.Register(userName, password).Result; stopwatch.Stop(); C.LogExecutionTime("Register new user", stopwatch); if (!string.IsNullOrEmpty(registerData)) { C.Log(registerData); success = true; } else { C.Log(registerData); success = false; } C.Log(); C.Log("========================================================"); C.Log(); } while (!success); }
private static void UserLogin() { AccessToken userData = null; do { success = true; C.Write("Username:\t"); string userName = C.Read(); C.Write("Password:\t"); string password = C.ReadPassword(); stopwatch.Restart(); //AccessToken data = C.CallService<AccessToken, object>(Method.POST, Url.Login, login, HttpHeaders.FormUrlEncoded, false).Result; userData = C.Login(userName, password).Result; stopwatch.Stop(); C.LogExecutionTime("User Login", stopwatch); if (userData != null) { C.Log("Login Successfull"); success = true; } else { C.Log("Username or Password is incorrect"); success = false; C.Read(); } C.Log(); C.Log("========================================================"); C.Log(); } while (!success); if (success) { if (userData.IsActive) { Services.AccessToken = userData.Access; Encryption.PublicKey = userData.PublicKey; LoggedIn = true; } else { success = false; Services.AccessToken = userData.Access; C.Log(); C.Log("========================================================"); C.Log("You have been deactived from the system."); C.Log("========================================================"); } } }