public async Task <bool> SetPasswordForUsername(string username, string password) { if (string.IsNullOrEmpty(username) || String.IsNullOrEmpty(password)) { return(false); } KeychainHelpers.SetPasswordForUsername(username, password, "XamarinExpenses", Security.SecAccessible.Always, true); NSUserDefaults.StandardUserDefaults.SetString(username, "username"); NSUserDefaults.StandardUserDefaults.SetBool(true, "hasLogin"); NSUserDefaults.StandardUserDefaults.Synchronize(); return(true); }
public async Task <bool> CheckLogin(string username, string password) { var _username = NSUserDefaults.StandardUserDefaults.ValueForKey(new NSString("username")); var _password = KeychainHelpers.GetPasswordForUsername(username, "XamarinExpenses", true); if (_username == null || _password == null) { return(false); } if (password == _password && username == _username.ToString()) { return(true); } return(false); }
public NSString ClearKeychain(NSString username) { NSUserDefaults.StandardUserDefaults.RemoveObject("username"); KeychainHelpers.DeletePasswordForUsername(username, "XamarinExpenses", true); return(new NSString()); }