This commit is contained in:
MeysamMoghaddam
2025-10-20 21:02:13 +03:30
parent 4c022f18c6
commit 59e58abaf9
2 changed files with 22 additions and 2 deletions

View File

@@ -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
{

View File

@@ -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);
}
}