user method
Gets the authenticated user from session
token In web context, this is the session ID
Implementation
@override
Future<Authenticatable> user(String sessionId) async {
if (_sessionManager == null) {
throw AuthException(
'Session manager not available for web authentication',
);
}
// Try to get user ID from session
final userId = await _getUserIdFromSession(sessionId);
if (userId == null) {
throw AuthException('User not authenticated');
}
// Get user from database
final provider = config.getProvider(providerKey);
final table = provider['table'] as String;
final primaryKey = provider['primary_key'] as String;
final userData = await repository.findUserById(userId, table, primaryKey);
if (userData == null) {
throw AuthException('User not found');
}
return _createAuthenticatable(userData);
}