mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
load login page after registration
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Bit.App.Utilities;
|
using Bit.App.Utilities;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Bit.App.Pages
|
namespace Bit.App.Pages
|
||||||
@@ -13,6 +14,12 @@ namespace Bit.App.Pages
|
|||||||
_logo.Source = theme == "dark" || theme == "black" ? "logo_white.png" : "logo.png";
|
_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)
|
private void LogIn_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if(DoOnce())
|
if(DoOnce())
|
||||||
@@ -25,7 +32,7 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
if(DoOnce())
|
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;
|
private LoginPageViewModel _vm;
|
||||||
|
|
||||||
public LoginPage()
|
public LoginPage(string email = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_vm = BindingContext as LoginPageViewModel;
|
_vm = BindingContext as LoginPageViewModel;
|
||||||
_vm.Page = this;
|
_vm.Page = this;
|
||||||
|
_vm.Email = email;
|
||||||
MasterPasswordEntry = _masterPassword;
|
MasterPasswordEntry = _masterPassword;
|
||||||
|
|
||||||
_email.ReturnType = ReturnType.Next;
|
_email.ReturnType = ReturnType.Next;
|
||||||
|
|||||||
@@ -7,11 +7,18 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
private RegisterPageViewModel _vm;
|
private RegisterPageViewModel _vm;
|
||||||
|
|
||||||
public RegisterPage()
|
public RegisterPage(HomePage homePage)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_vm = BindingContext as RegisterPageViewModel;
|
_vm = BindingContext as RegisterPageViewModel;
|
||||||
_vm.Page = this;
|
_vm.Page = this;
|
||||||
|
_vm.RegistrationSuccess = async () =>
|
||||||
|
{
|
||||||
|
if(homePage != null)
|
||||||
|
{
|
||||||
|
await homePage.DismissRegisterPageAndLogInAsync(_vm.Email);
|
||||||
|
}
|
||||||
|
};
|
||||||
MasterPasswordEntry = _masterPassword;
|
MasterPasswordEntry = _masterPassword;
|
||||||
ConfirmMasterPasswordEntry = _confirmMasterPassword;
|
ConfirmMasterPasswordEntry = _confirmMasterPassword;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Bit.Core.Enums;
|
|||||||
using Bit.Core.Exceptions;
|
using Bit.Core.Exceptions;
|
||||||
using Bit.Core.Models.Request;
|
using Bit.Core.Models.Request;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
@@ -16,7 +17,6 @@ namespace Bit.App.Pages
|
|||||||
private readonly IApiService _apiService;
|
private readonly IApiService _apiService;
|
||||||
private readonly ICryptoService _cryptoService;
|
private readonly ICryptoService _cryptoService;
|
||||||
private readonly IPlatformUtilsService _platformUtilsService;
|
private readonly IPlatformUtilsService _platformUtilsService;
|
||||||
|
|
||||||
private bool _showPassword;
|
private bool _showPassword;
|
||||||
|
|
||||||
public RegisterPageViewModel()
|
public RegisterPageViewModel()
|
||||||
@@ -26,7 +26,7 @@ namespace Bit.App.Pages
|
|||||||
_cryptoService = ServiceContainer.Resolve<ICryptoService>("cryptoService");
|
_cryptoService = ServiceContainer.Resolve<ICryptoService>("cryptoService");
|
||||||
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||||
|
|
||||||
PageTitle = AppResources.Bitwarden;
|
PageTitle = AppResources.CreateAccount;
|
||||||
TogglePasswordCommand = new Command(TogglePassword);
|
TogglePasswordCommand = new Command(TogglePassword);
|
||||||
ToggleConfirmPasswordCommand = new Command(ToggleConfirmPassword);
|
ToggleConfirmPasswordCommand = new Command(ToggleConfirmPassword);
|
||||||
SubmitCommand = new Command(async () => await SubmitAsync());
|
SubmitCommand = new Command(async () => await SubmitAsync());
|
||||||
@@ -51,6 +51,7 @@ namespace Bit.App.Pages
|
|||||||
public string MasterPassword { get; set; }
|
public string MasterPassword { get; set; }
|
||||||
public string ConfirmMasterPassword { get; set; }
|
public string ConfirmMasterPassword { get; set; }
|
||||||
public string Hint { get; set; }
|
public string Hint { get; set; }
|
||||||
|
public Action RegistrationSuccess { get; set; }
|
||||||
|
|
||||||
public async Task SubmitAsync()
|
public async Task SubmitAsync()
|
||||||
{
|
{
|
||||||
@@ -121,10 +122,15 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _deviceActionService.ShowLoadingAsync(AppResources.LoggingIn);
|
await _deviceActionService.ShowLoadingAsync(AppResources.CreatingAccount);
|
||||||
await _apiService.PostRegisterAsync(request);
|
await _apiService.PostRegisterAsync(request);
|
||||||
await _deviceActionService.HideLoadingAsync();
|
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)
|
catch(ApiException e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user