u
This commit is contained in:
@@ -44,7 +44,11 @@
|
||||
<MudHidden Breakpoint="Breakpoint.SmAndUp" Invert="true">
|
||||
@if (_isAuthenticated)
|
||||
{
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Inherit" OnClick="NavigateToProfile">پروفایل</MudButton>
|
||||
<MudMenu Icon="@Icons.Material.Filled.Person" Color="Color.Inherit" Size="Size.Medium">
|
||||
<MudMenuItem OnClick="NavigateToProfile">پروفایل</MudMenuItem>
|
||||
<MudDivider />
|
||||
<MudMenuItem OnClick="Logout">خروج از حساب</MudMenuItem>
|
||||
</MudMenu>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -69,6 +73,7 @@
|
||||
@if (_isAuthenticated)
|
||||
{
|
||||
<MudButton Href="/profile" Color="Color.Primary" OnClick="() => _drawerOpen=false">پروفایل</MudButton>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Error" OnClick="() => { _drawerOpen=false; Logout(); }">خروج از حساب</MudButton>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -57,4 +57,19 @@ public partial class MainLayout
|
||||
{
|
||||
Navigation.NavigateTo(RouteConstants.Profile.Index);
|
||||
}
|
||||
|
||||
private async Task Logout()
|
||||
{
|
||||
await LocalStorage.RemoveItemAsync(TokenStorageKey);
|
||||
await LocalStorage.RemoveItemAsync("auth:phone-number");
|
||||
await LocalStorage.RemoveItemAsync("auth:redirect");
|
||||
await LocalStorage.RemoveItemAsync("referral:code");
|
||||
|
||||
_isAuthenticated = false;
|
||||
Snackbar.Add("با موفقیت از حساب کاربری خارج شدید.", Severity.Success);
|
||||
StateHasChanged();
|
||||
|
||||
// Navigate to home page
|
||||
Navigation.NavigateTo(RouteConstants.Main.MainPage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user