Exemplo n.º 1
0
 public NSString CreateLogin(NSString nothing)
 {
     KeychainHelpers.SetPasswordForUsername("admin", "password", "XamarinExpenses", Security.SecAccessible.Always, true);
     NSUserDefaults.StandardUserDefaults.SetString("admin", "username");
     NSUserDefaults.StandardUserDefaults.Synchronize();
     return(new NSString());
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public NSString ClearKeychain(NSString nothing)
 {
     NSUserDefaults.StandardUserDefaults.RemoveObject("username");
     KeychainHelpers.DeletePasswordForUsername("Michael", "XamarinExpenses", true);
     return(new NSString());
 }