mirror of
https://github.com/bitwarden/mobile
synced 2026-01-03 09:03:35 +00:00
Centralized logout into a message subscription in app class. Logout when API results are forbidden or unauthorized.
This commit is contained in:
@@ -6,6 +6,7 @@ using Bit.App.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Bit.App.Models.Data;
|
||||
using Bit.App.Models.Api;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Services
|
||||
{
|
||||
@@ -71,6 +72,11 @@ namespace Bit.App.Services
|
||||
await _folderRepository.UpdateAsync(data);
|
||||
}
|
||||
}
|
||||
else if(response.StatusCode == System.Net.HttpStatusCode.Forbidden
|
||||
|| response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -82,6 +88,11 @@ namespace Bit.App.Services
|
||||
{
|
||||
await _folderRepository.DeleteAsync(folderId);
|
||||
}
|
||||
else if(response.StatusCode == System.Net.HttpStatusCode.Forbidden
|
||||
|| response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Bit.App.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Bit.App.Models.Api;
|
||||
using Bit.App.Models.Data;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Services
|
||||
{
|
||||
@@ -78,6 +79,11 @@ namespace Bit.App.Services
|
||||
await _siteRepository.UpdateAsync(data);
|
||||
}
|
||||
}
|
||||
else if(response.StatusCode == System.Net.HttpStatusCode.Forbidden
|
||||
|| response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -89,6 +95,11 @@ namespace Bit.App.Services
|
||||
{
|
||||
await _siteRepository.DeleteAsync(id);
|
||||
}
|
||||
else if(response.StatusCode == System.Net.HttpStatusCode.Forbidden
|
||||
|| response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,13 @@ namespace Bit.App.Services
|
||||
if(!cipher.Succeeded)
|
||||
{
|
||||
SyncCompleted(false);
|
||||
|
||||
if(cipher.StatusCode == System.Net.HttpStatusCode.Forbidden
|
||||
|| cipher.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -136,6 +143,13 @@ namespace Bit.App.Services
|
||||
if(!ciphers.Succeeded)
|
||||
{
|
||||
SyncCompleted(false);
|
||||
|
||||
if(ciphers.StatusCode == System.Net.HttpStatusCode.Forbidden
|
||||
|| ciphers.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -174,6 +188,13 @@ namespace Bit.App.Services
|
||||
if(!ciphers.Succeeded)
|
||||
{
|
||||
SyncCompleted(false);
|
||||
|
||||
if(ciphers.StatusCode == System.Net.HttpStatusCode.Forbidden
|
||||
|| ciphers.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "Logout", (string)null);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user