mirror of
https://github.com/bitwarden/android.git
synced 2025-01-11 18:57:39 +03:00
load login page after registration
This commit is contained in:
parent
b67adf8789
commit
b29ccf67b1
4 changed files with 28 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
using Bit.App.Utilities;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
|
@ -13,6 +14,12 @@ namespace Bit.App.Pages
|
|||
_logo.Source = theme == "dark" || theme == "black" ? "logo_white.png" : "logo.png";
|
||||
}
|
||||
|
||||
public async Task DismissRegisterPageAndLogInAsync(string email)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PushModalAsync(new NavigationPage(new LoginPage(email)));
|
||||
}
|
||||
|
||||
private void LogIn_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
if(DoOnce())
|
||||
|
@ -25,7 +32,7 @@ namespace Bit.App.Pages
|
|||
{
|
||||
if(DoOnce())
|
||||
{
|
||||
Navigation.PushModalAsync(new NavigationPage(new RegisterPage()));
|
||||
Navigation.PushModalAsync(new NavigationPage(new RegisterPage(this)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,12 @@ namespace Bit.App.Pages
|
|||
{
|
||||
private LoginPageViewModel _vm;
|
||||
|
||||
public LoginPage()
|
||||
public LoginPage(string email = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
_vm = BindingContext as LoginPageViewModel;
|
||||
_vm.Page = this;
|
||||
_vm.Email = email;
|
||||
MasterPasswordEntry = _masterPassword;
|
||||
|
||||
_email.ReturnType = ReturnType.Next;
|
||||
|
|
|
@ -7,11 +7,18 @@ namespace Bit.App.Pages
|
|||
{
|
||||
private RegisterPageViewModel _vm;
|
||||
|
||||
public RegisterPage()
|
||||
public RegisterPage(HomePage homePage)
|
||||
{
|
||||
InitializeComponent();
|
||||
_vm = BindingContext as RegisterPageViewModel;
|
||||
_vm.Page = this;
|
||||
_vm.RegistrationSuccess = async () =>
|
||||
{
|
||||
if(homePage != null)
|
||||
{
|
||||
await homePage.DismissRegisterPageAndLogInAsync(_vm.Email);
|
||||
}
|
||||
};
|
||||
MasterPasswordEntry = _masterPassword;
|
||||
ConfirmMasterPasswordEntry = _confirmMasterPassword;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using Bit.Core.Enums;
|
|||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Request;
|
||||
using Bit.Core.Utilities;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
|
@ -16,7 +17,6 @@ namespace Bit.App.Pages
|
|||
private readonly IApiService _apiService;
|
||||
private readonly ICryptoService _cryptoService;
|
||||
private readonly IPlatformUtilsService _platformUtilsService;
|
||||
|
||||
private bool _showPassword;
|
||||
|
||||
public RegisterPageViewModel()
|
||||
|
@ -26,7 +26,7 @@ namespace Bit.App.Pages
|
|||
_cryptoService = ServiceContainer.Resolve<ICryptoService>("cryptoService");
|
||||
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||
|
||||
PageTitle = AppResources.Bitwarden;
|
||||
PageTitle = AppResources.CreateAccount;
|
||||
TogglePasswordCommand = new Command(TogglePassword);
|
||||
ToggleConfirmPasswordCommand = new Command(ToggleConfirmPassword);
|
||||
SubmitCommand = new Command(async () => await SubmitAsync());
|
||||
|
@ -51,6 +51,7 @@ namespace Bit.App.Pages
|
|||
public string MasterPassword { get; set; }
|
||||
public string ConfirmMasterPassword { get; set; }
|
||||
public string Hint { get; set; }
|
||||
public Action RegistrationSuccess { get; set; }
|
||||
|
||||
public async Task SubmitAsync()
|
||||
{
|
||||
|
@ -121,10 +122,15 @@ namespace Bit.App.Pages
|
|||
|
||||
try
|
||||
{
|
||||
await _deviceActionService.ShowLoadingAsync(AppResources.LoggingIn);
|
||||
await _deviceActionService.ShowLoadingAsync(AppResources.CreatingAccount);
|
||||
await _apiService.PostRegisterAsync(request);
|
||||
await _deviceActionService.HideLoadingAsync();
|
||||
// TODO: dismiss this page from home page and pass email for login page
|
||||
_platformUtilsService.ShowToast("success", null, AppResources.AccountCreated,
|
||||
new System.Collections.Generic.Dictionary<string, object>
|
||||
{
|
||||
["longDuration"] = true
|
||||
});
|
||||
RegistrationSuccess?.Invoke();
|
||||
}
|
||||
catch(ApiException e)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue