mirror of
https://github.com/bitwarden/mobile
synced 2025-12-12 14:23:26 +00:00
[Reset Password v1] Update Temp Password (#1492)
* [Reset Password v1] Update Temp Password * fixed order of operations for reset temp password flow * Refactored bool with auth result * Finished removal of temp password flow from set password * iOS extension support plus extension bugfixes Co-authored-by: addison <addisonbeck1@gmail.com> Co-authored-by: Matt Portune <mportune@bitwarden.com>
This commit is contained in:
@@ -300,6 +300,22 @@ namespace Bit.iOS.Autofill
|
||||
return userService.IsAuthenticatedAsync();
|
||||
}
|
||||
|
||||
private void LogoutIfAuthed()
|
||||
{
|
||||
NSRunLoop.Main.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
if (await IsAuthed())
|
||||
{
|
||||
await AppHelpers.LogOutAsync();
|
||||
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
if (deviceActionService.SystemMajorVersion() >= 12)
|
||||
{
|
||||
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void InitApp()
|
||||
{
|
||||
// Init Xamarin Forms
|
||||
@@ -353,6 +369,8 @@ namespace Bit.iOS.Autofill
|
||||
var loginController = navigationPage.CreateViewController();
|
||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(loginController, true, null);
|
||||
|
||||
LogoutIfAuthed();
|
||||
}
|
||||
|
||||
private void LaunchEnvironmentFlow()
|
||||
@@ -400,6 +418,7 @@ namespace Bit.iOS.Autofill
|
||||
if (loginPage.BindingContext is LoginPageViewModel vm)
|
||||
{
|
||||
vm.StartTwoFactorAction = () => DismissViewController(false, () => LaunchTwoFactorFlow(false));
|
||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||
vm.LogInSuccessAction = () => DismissLockAndContinue();
|
||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
}
|
||||
@@ -408,6 +427,8 @@ namespace Bit.iOS.Autofill
|
||||
var loginController = navigationPage.CreateViewController();
|
||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(loginController, true, null);
|
||||
|
||||
LogoutIfAuthed();
|
||||
}
|
||||
|
||||
private void LaunchLoginSsoFlow()
|
||||
@@ -420,6 +441,7 @@ namespace Bit.iOS.Autofill
|
||||
{
|
||||
vm.StartTwoFactorAction = () => DismissViewController(false, () => LaunchTwoFactorFlow(true));
|
||||
vm.StartSetPasswordAction = () => DismissViewController(false, () => LaunchSetPasswordFlow());
|
||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||
vm.SsoAuthSuccessAction = () => DismissLockAndContinue();
|
||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
}
|
||||
@@ -428,6 +450,8 @@ namespace Bit.iOS.Autofill
|
||||
var loginController = navigationPage.CreateViewController();
|
||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(loginController, true, null);
|
||||
|
||||
LogoutIfAuthed();
|
||||
}
|
||||
|
||||
private void LaunchTwoFactorFlow(bool authingWithSso)
|
||||
@@ -448,6 +472,7 @@ namespace Bit.iOS.Autofill
|
||||
{
|
||||
vm.CloseAction = () => DismissViewController(false, () => LaunchLoginFlow());
|
||||
}
|
||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||
}
|
||||
|
||||
var navigationPage = new NavigationPage(twoFactorPage);
|
||||
@@ -464,6 +489,7 @@ namespace Bit.iOS.Autofill
|
||||
ThemeManager.ApplyResourcesToPage(setPasswordPage);
|
||||
if (setPasswordPage.BindingContext is SetPasswordPageViewModel vm)
|
||||
{
|
||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||
vm.SetPasswordSuccessAction = () => DismissLockAndContinue();
|
||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
}
|
||||
@@ -473,5 +499,23 @@ namespace Bit.iOS.Autofill
|
||||
setPasswordController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(setPasswordController, true, null);
|
||||
}
|
||||
|
||||
private void LaunchUpdateTempPasswordFlow()
|
||||
{
|
||||
var updateTempPasswordPage = new UpdateTempPasswordPage();
|
||||
var app = new App.App(new AppOptions { IosExtension = true });
|
||||
ThemeManager.SetTheme(false, app.Resources);
|
||||
ThemeManager.ApplyResourcesToPage(updateTempPasswordPage);
|
||||
if (updateTempPasswordPage.BindingContext is UpdateTempPasswordPageViewModel vm)
|
||||
{
|
||||
vm.UpdateTempPasswordSuccessAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
vm.LogOutAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||
}
|
||||
|
||||
var navigationPage = new NavigationPage(updateTempPasswordPage);
|
||||
var updateTempPasswordController = navigationPage.CreateViewController();
|
||||
updateTempPasswordController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||
PresentViewController(updateTempPasswordController, true, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user