public static UsernamePassword ( string username, string password, bool createUser ) : |
||
username | string | The username of the user. |
password | string | The user's password. |
createUser | bool | |
리턴 |
void btnLogin_Clicked(object sender, System.EventArgs e) { _credentials = Credentials.UsernamePassword(txt_un.Text, txt_pw.Text, false); stk_login.IsVisible = false; stk_form.IsVisible = true; if (App.Current.Properties.ContainsKey("username")) { App.Current.Properties["username"] = txt_un.Text; } else { App.Current.Properties.Add("username", txt_un.Text); } if (App.Current.Properties.ContainsKey("password")) { App.Current.Properties["password"] = txt_pw.Text; } else { App.Current.Properties.Add("password", txt_pw.Text); } }
private async TTask Login() { var cts = new CancellationTokenSource(); cts.CancelAfter(TimeSpan.FromMinutes(1)); await Do( func : async() => { Realm.Write(() => { LoginInfo.ServerUrl = LoginInfo.ServerUrl.Replace("http://", string.Empty) .Replace("https://", string.Empty) .Replace("realm://", string.Empty) .Replace("realms://", string.Empty); }); Constants.Server.RealmServerAddress = LoginInfo.ServerUrl; var credentials = Credentials.UsernamePassword(LoginInfo.Username, Password, false); await User.LoginAsync(credentials, new Uri(Constants.Server.AuthServerUrl)); CoreMethods.SwitchOutRootNavigation(NavigationContainerNames.MainContainer); }, onError : async ex => { await TTask.Delay(500, cts.Token); UserDialogs.Instance.Alert("Unable to login!", ex.Message); LogException(ex); }, loadingMessage : "Logging in...", token : cts.Token ); }
async void btnPerm_Clicked(object sender, System.EventArgs e) { Credentials creds = Credentials.UsernamePassword("realmroot", "realmroot1234", false); User user = await User.LoginAsync(creds, new Uri(Constants.AuthUrl)); var condition = PermissionCondition.Default; await user.ApplyPermissionsAsync(condition, Constants.RealmPath + "beer", AccessLevel.Read); }
private async Task Initialize() { InitializeComponent(); await Task.Yield(); lbl_status.Text = "Ready..."; if (App.Current.Properties.ContainsKey("username") && App.Current.Properties.ContainsKey("password")) { stk_login.IsVisible = false; stk_form.IsVisible = true; _credentials = Credentials.UsernamePassword((string)App.Current.Properties["username"], (string)App.Current.Properties["password"], false); } else { stk_login.IsVisible = true; stk_form.IsVisible = false; } }
private async Task <Realm> OpenRealm() { try { _credentials = Credentials.UsernamePassword((string)App.Current.Properties["username"], (string)App.Current.Properties["password"], false); User user = await User.LoginAsync(_credentials, new Uri(Constants.AuthUrl)); var configuration = new FullSyncConfiguration(new Uri(Constants.RealmPath + ddl_realm.SelectedItem.ToString()), user); var realm = Realm.GetInstance(configuration); return(realm); } catch (Exception ex) { lbl_status.Text = ex.Message; // Try again return(await OpenRealm()); } }