reorg
This commit is contained in:
parent
c745aef6d7
commit
3bf7dd88f5
3 changed files with 34 additions and 9 deletions
21
src/PostIt/PostIt/Exceptions/NoTokenException.cs
Normal file
21
src/PostIt/PostIt/Exceptions/NoTokenException.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
|
||||
namespace Yavsc.Exceptions;
|
||||
|
||||
public class NoTokenException : Exception
|
||||
{
|
||||
public NoTokenException()
|
||||
: base("No token available.")
|
||||
{
|
||||
}
|
||||
|
||||
public NoTokenException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public NoTokenException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
10
src/PostIt/PostIt/Exceptions/RefreshFailedException.cs
Normal file
10
src/PostIt/PostIt/Exceptions/RefreshFailedException.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace PostIt.Services;
|
||||
|
||||
public sealed class RefreshFailedException : Exception
|
||||
{
|
||||
public bool IsPermanent { get; }
|
||||
public RefreshFailedException(string message, bool isPermanent)
|
||||
: base(message) => IsPermanent = isPermanent;
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ using IdentityModel.OidcClient;
|
|||
using PostIt.ViewModels;
|
||||
using Yavsc.ApiControllers;
|
||||
using Yavsc.Api.Client;
|
||||
using Yavsc.Exceptions;
|
||||
|
||||
namespace PostIt.Services;
|
||||
|
||||
|
|
@ -547,10 +548,10 @@ public class YavscApiClient : IYavscApiClient, IAsyncDisposable
|
|||
try
|
||||
{
|
||||
if (IsSigningOut)
|
||||
throw new InvalidOperationException("Deconnexion en cours.");
|
||||
throw new NoTokenException("Deconnexion en cours.");
|
||||
var tokens = _tokens;
|
||||
if (tokens is null)
|
||||
throw new InvalidOperationException("Session expirée. Veuillez vous reconnecter.");
|
||||
throw new NoTokenException("Session expirée. Veuillez vous reconnecter.");
|
||||
if (string.IsNullOrEmpty(tokens.RefreshToken))
|
||||
{
|
||||
_store.Clear();
|
||||
|
|
@ -852,10 +853,3 @@ public class YavscApiClient : IYavscApiClient, IAsyncDisposable
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RefreshFailedException : Exception
|
||||
{
|
||||
public bool IsPermanent { get; }
|
||||
public RefreshFailedException(string message, bool isPermanent)
|
||||
: base(message) => IsPermanent = isPermanent;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue