Beispiel #1
0
        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);
        }
Beispiel #2
0
        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 noValue)
 {
     NSUserDefaults.StandardUserDefaults.RemoveObject("username");
     KeychainHelpers.DeletePasswordForUsername("Brandon", "XamarinExpenses", true);
     return(new NSString());
 }