mirror of
https://github.com/bitwarden/mobile
synced 2026-01-08 11:33:31 +00:00
Centralized logout into a message subscription in app class. Logout when API results are forbidden or unauthorized.
This commit is contained in:
@@ -14,7 +14,6 @@ namespace Bit.App.Pages
|
||||
public class LockFingerprintPage : ExtendedContentPage
|
||||
{
|
||||
private readonly IFingerprint _fingerprint;
|
||||
private readonly IAuthService _authService;
|
||||
private readonly IUserDialogs _userDialogs;
|
||||
private readonly ISettings _settings;
|
||||
private readonly bool _checkFingerprintImmediately;
|
||||
@@ -24,7 +23,6 @@ namespace Bit.App.Pages
|
||||
{
|
||||
_checkFingerprintImmediately = checkFingerprintImmediately;
|
||||
_fingerprint = Resolver.Resolve<IFingerprint>();
|
||||
_authService = Resolver.Resolve<IAuthService>();
|
||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||
_settings = Resolver.Resolve<ISettings>();
|
||||
|
||||
@@ -79,9 +77,7 @@ namespace Bit.App.Pages
|
||||
return;
|
||||
}
|
||||
|
||||
_authService.LogOut();
|
||||
await Navigation.PopModalAsync();
|
||||
Application.Current.MainPage = new HomePage();
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
public async Task CheckFingerprintAsync()
|
||||
|
||||
@@ -123,9 +123,7 @@ namespace Bit.App.Pages
|
||||
return;
|
||||
}
|
||||
|
||||
_authService.LogOut();
|
||||
await Navigation.PopModalAsync();
|
||||
Application.Current.MainPage = new HomePage();
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,9 +102,7 @@ namespace Bit.App.Pages
|
||||
return;
|
||||
}
|
||||
|
||||
_authService.LogOut();
|
||||
await Navigation.PopModalAsync();
|
||||
Application.Current.MainPage = new HomePage();
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Bit.App.Resources;
|
||||
using Plugin.Connectivity.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
@@ -74,8 +75,16 @@ namespace Bit.App.Pages
|
||||
await saveTask;
|
||||
|
||||
_userDialogs.HideLoading();
|
||||
await Navigation.PopModalAsync();
|
||||
_userDialogs.SuccessToast(nameCell.Entry.Text, "New folder created.");
|
||||
|
||||
if(saveTask.Result.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
_userDialogs.SuccessToast(nameCell.Entry.Text, "New folder created.");
|
||||
}
|
||||
else if(saveTask.Result.Errors.Count() > 0)
|
||||
{
|
||||
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||
}
|
||||
}, ToolbarItemOrder.Default, 0);
|
||||
|
||||
Title = "Add Folder";
|
||||
|
||||
@@ -6,6 +6,7 @@ using Bit.App.Resources;
|
||||
using Plugin.Connectivity.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
@@ -87,8 +88,16 @@ namespace Bit.App.Pages
|
||||
await saveTask;
|
||||
|
||||
_userDialogs.HideLoading();
|
||||
await Navigation.PopModalAsync();
|
||||
_userDialogs.SuccessToast(nameCell.Entry.Text, "Folder updated.");
|
||||
|
||||
if(saveTask.Result.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
_userDialogs.SuccessToast(nameCell.Entry.Text, "Folder updated.");
|
||||
}
|
||||
else if(saveTask.Result.Errors.Count() > 0)
|
||||
{
|
||||
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||
}
|
||||
}, ToolbarItemOrder.Default, 0);
|
||||
|
||||
Title = "Edit Folder";
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Bit.App.Pages
|
||||
}
|
||||
};
|
||||
|
||||
if( Device.OS == TargetPlatform.iOS )
|
||||
if(Device.OS == TargetPlatform.iOS)
|
||||
{
|
||||
table.RowHeight = -1;
|
||||
table.EstimatedRowHeight = 44;
|
||||
@@ -199,9 +199,7 @@ namespace Bit.App.Pages
|
||||
return;
|
||||
}
|
||||
|
||||
_authService.LogOut();
|
||||
_pushNotification.Unregister();
|
||||
Application.Current.MainPage = new HomePage();
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
private async void ChangeMasterPasswordCell_Tapped(object sender, EventArgs e)
|
||||
|
||||
@@ -134,8 +134,15 @@ namespace Bit.App.Pages
|
||||
await saveTask;
|
||||
|
||||
_userDialogs.HideLoading();
|
||||
await Navigation.PopModalAsync();
|
||||
_userDialogs.SuccessToast(nameCell.Entry.Text, "New site created.");
|
||||
if(saveTask.Result.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
_userDialogs.SuccessToast(nameCell.Entry.Text, "New site created.");
|
||||
}
|
||||
else if(saveTask.Result.Errors.Count() > 0)
|
||||
{
|
||||
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||
}
|
||||
}, ToolbarItemOrder.Default, 0);
|
||||
|
||||
Title = AppResources.AddSite;
|
||||
|
||||
@@ -168,8 +168,16 @@ namespace Bit.App.Pages
|
||||
await saveTask;
|
||||
|
||||
_userDialogs.HideLoading();
|
||||
await Navigation.PopModalAsync();
|
||||
_userDialogs.SuccessToast(nameCell.Entry.Text, "Site updated.");
|
||||
|
||||
if(saveTask.Result.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
_userDialogs.SuccessToast(nameCell.Entry.Text, "Site updated.");
|
||||
}
|
||||
else if(saveTask.Result.Errors.Count() > 0)
|
||||
{
|
||||
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||
}
|
||||
}, ToolbarItemOrder.Default, 0);
|
||||
|
||||
Title = "Edit Site";
|
||||
|
||||
Reference in New Issue
Block a user