Update App.razor.cs
This commit is contained in:
@@ -15,15 +15,11 @@ public partial class App
|
||||
{
|
||||
var normalizedPath = NormalizePath(context.Path);
|
||||
if (IsAuthPath(normalizedPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var token = await LocalStorage.GetItemAsync<string>(TokenStorageKey);
|
||||
if (!string.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var redirect = string.IsNullOrEmpty(normalizedPath) || normalizedPath == "/"
|
||||
? string.Empty
|
||||
@@ -35,14 +31,10 @@ public partial class App
|
||||
private static bool IsAuthPath(string? path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Uri.TryCreate(path, UriKind.Absolute, out var absolute))
|
||||
{
|
||||
path = absolute.PathAndQuery;
|
||||
}
|
||||
|
||||
path = path.TrimStart('/');
|
||||
return path.StartsWith("auth", StringComparison.OrdinalIgnoreCase);
|
||||
@@ -51,14 +43,10 @@ public partial class App
|
||||
private static string NormalizePath(string? path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (Uri.TryCreate(path, UriKind.Absolute, out var absolute))
|
||||
{
|
||||
path = absolute.PathAndQuery;
|
||||
}
|
||||
|
||||
return path.StartsWith('/') ? path : "/" + path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user