update method
Updates an auth user.
When updating scopes or the blocked status of an auth user, you may need
to communicate these changes to the rest of the server using
session.messages.authenticationRevoked with an appropriate message type
(e.g., RevokedAuthenticationUser or RevokedAuthenticationScope).
Throws an AuthUserNotFoundException in case no auth user is found for the ID.
Implementation
Future<AuthUserModel> update(
final Session session, {
required final UuidValue authUserId,
final Set<Scope>? scopes,
final bool? blocked,
final Transaction? transaction,
}) async {
return DatabaseUtil.runInTransactionOrSavepoint(session.db, transaction, (
final transaction,
) async {
var authUser = await AuthUser.db.findById(
session,
authUserId,
transaction: transaction,
);
if (authUser == null) {
throw AuthUserNotFoundException();
}
if (scopes != null) {
authUser = authUser.copyWith(
scopeNames: scopes.map((final s) => s.name).nonNulls.toSet(),
);
}
if (blocked != null) {
authUser = authUser.copyWith(
blocked: blocked,
);
}
authUser = await AuthUser.db.updateRow(
session,
authUser,
transaction: transaction,
);
return authUser.toModel();
});
}