formatted the whole codebase

This commit is contained in:
asif
2025-08-18 03:20:05 +05:30
parent e2a809d363
commit e6ea764785
58 changed files with 470 additions and 373 deletions

View File

@@ -10,7 +10,7 @@ class AuthRepository {
final AuthService _authService;
final UserService _userService;
final SecureStorage _secureStorage;
static const _accessTokenKey = 'access_token';
static const _tokenExpiryKey = 'token_expiry';
@@ -18,35 +18,37 @@ class AuthRepository {
Future<List<User>> login(String customerNo, String password) async {
// Create credentials and call service
final credentials = AuthCredentials(customerNo: customerNo, password: password);
final credentials =
AuthCredentials(customerNo: customerNo, password: password);
final authToken = await _authService.login(credentials);
// Save token securely
await _saveAuthToken(authToken);
// Get and save user profile
final users = await _userService.getUserDetails();
return users;
}
Future<bool> isLoggedIn() async {
final token = await _getAuthToken();
return token != null && !token.isExpired;
}
Future<String?> getAccessToken() async {
final token = await _getAuthToken();
if (token == null) return null;
return token.accessToken;
}
// Private helper methods
Future<void> _saveAuthToken(AuthToken token) async {
await _secureStorage.write(_accessTokenKey, token.accessToken);
await _secureStorage.write(_tokenExpiryKey, token.expiresAt.toIso8601String());
await _secureStorage.write(
_tokenExpiryKey, token.expiresAt.toIso8601String());
}
Future<AuthToken?> _getAuthToken() async {
final accessToken = await _secureStorage.read(_accessTokenKey);
final expiryString = await _secureStorage.read(_tokenExpiryKey);
@@ -59,4 +61,4 @@ class AuthRepository {
}
return null;
}
}
}