findSessions method
Future<List<AuthSessionInfo> >
findSessions(
- Session session, {
- UuidValue? authUserId,
- String? method,
- Transaction? transaction,
List all sessions matching the given filters.
Implementation
Future<List<AuthSessionInfo>> findSessions(
final Session session, {
final UuidValue? authUserId,
final String? method,
final Transaction? transaction,
}) async {
final authSessions = await AuthSession.db.find(
session,
where: (final t) {
Expression<dynamic> expression = Constant.bool(true);
if (authUserId != null) {
expression &= t.authUserId.equals(authUserId);
}
if (method != null) {
expression &= t.method.equals(method);
}
return expression;
},
transaction: transaction,
);
final sessionInfos = <AuthSessionInfo>[
for (final authSession in authSessions)
AuthSessionInfo(
id: authSession.id!,
authUserId: authSession.authUserId,
scopeNames: authSession.scopeNames,
created: authSession.createdAt,
lastUsed: authSession.lastUsedAt,
expiresAt: authSession.expiresAt,
expireAfterUnusedFor: authSession.expireAfterUnusedFor,
method: authSession.method,
),
];
return sessionInfos;
}