update static method
Updates an auth user.
Throws an AuthUserNotFoundException in case no auth user is found for the ID.
Implementation
static Future<AuthUserModel> update(
final Session session, {
required final UuidValue authUserId,
final Set<Scope>? scopes,
final bool? blocked,
final Transaction? 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();
}