Files
LoopFit/LoopFit/Services/TokenStorageService.cs
T
Natlinux b12e557e1a implement Clean Architecture and user authentication
- Add LoopFit.Domain with entities (ApplicationUser, Workout, CalorieEntry, VitalData), enums (WorkoutType), and interfaces (IJwtTokenGenerator, IUserRepository, IWorkoutRepository)
- Add LoopFit.Application with auth DTOs, service interfaces, and DI setup
- Add LoopFit.Infrastructure with EF Core DbContext (PostgreSQL), ASP.NET Core Identity, JWT token generation, and repository implementations
- Add AuthController with register/login/me endpoints and JWT Bearer auth
- Add MAUI auth services (AuthService, TokenStorageService) and Login/Register Blazor pages
2026-08-26 00:50:02 +02:00

30 lines
599 B
C#

namespace LoopFit.Services;
public class TokenStorageService
{
private const string TokenKey = "loopfit_jwt_token";
public async Task SaveTokenAsync(string token)
{
await SecureStorage.Default.SetAsync(TokenKey, token);
}
public async Task<string?> GetTokenAsync()
{
try
{
return await SecureStorage.Default.GetAsync(TokenKey);
}
catch
{
return null;
}
}
public Task RemoveTokenAsync()
{
SecureStorage.Default.Remove(TokenKey);
return Task.CompletedTask;
}
}