/// <summary> /// Starts the app /// </summary> /// <param name="hint">The hint object to use (See <see cref="CoreAppStart"/>) </param> public void Start(object hint = null) { CoreApp.Hint = (CoreAppStartHint)hint; if (CoreApp.Hint.LoginEnabled) { ShowViewModel <LoginViewModel>(); } else { CoreApp.StartSession(CoreApp.Hint.Username, null, null); ShowViewModel <TaskListsViewModel>(new { loginEnabled = false }); } }
private async Task Login(string password) { if (String.IsNullOrWhiteSpace(Username) || String.IsNullOrWhiteSpace(password)) { _dialogs.ShowError("Username or password cannot be empty"); return; } if (!LoginModel.IsValidUsername(Username)) { _dialogs.ShowError("Invalid username"); return; } try { CoreApp.StartSession(Username, password, null); } catch (CouchbaseLiteException e) { if (e.CBLStatus.Code == StatusCode.Unauthorized) { var result = await _dialogs.PromptAsync(new PromptConfig { Title = "Password Changed", OkText = "Migrate", CancelText = "Delete", IsCancellable = true, InputType = Acr.UserDialogs.InputType.Password }); if (result.Ok) { CoreApp.StartSession(Username, result.Text, password); } else { Model.DeleteDatabase(Username); Login(password); return; } } else { _dialogs.ShowError($"Login has an error occurred, code = {e.CBLStatus.Code}"); return; } } catch (Exception e) { _dialogs.ShowError($"Login has an error occurred, code = {e}"); return; } ShowViewModel <TaskListsViewModel>(new { loginEnabled = true }); }
/// <summary> /// Starts the app /// </summary> /// <param name="hint">The hint object to use (See <see cref="CoreAppStart"/>) </param> public void Start(object hint = null) { Couchbase.Lite.Storage.SQLCipher.Plugin.Register(); CoreApp.Hint = (CoreAppStartHint)hint; if (CoreApp.Hint.LoginEnabled) { ShowViewModel <LoginViewModel>(); } else { CoreApp.StartSession(CoreApp.Hint.Username, null, null); ShowViewModel <TaskListsViewModel>(new { loginEnabled = false }); } }