public static bool Login(string Username, string Password) { RestClient Client = new RestClient(); string PasswordHash = Authentication.HashCredentials(Username, Password); User User; // Get public token from server RestRequest Request = new RestRequest(AuthURL + Android.OS.Build.Model + "/" + Username + "/" + PasswordHash, Method.GET); Config.CreateConfig(Client.Execute(Request).Content); AuthUser AuthUser = new AuthUser { Username = Username, PasswordHash = PasswordHash, PublicToken = Config.DevicePublicToken }; try { Request = new RestRequest(UserURL, Method.POST); Request.AddJsonBody(AuthUser); User = Client.Execute <User>(Request).Data; } catch { User = new User(); } if (User.Username == null) { return(false); } try { StoreAccount.StoreUser(User); return(true); } catch { return(false); } }
public static void LogOut() { StoreAccount.DeleteDB(); CrossCurrentActivity.Current.Activity.StartActivity(typeof(LoginActivity)); }