blockUser static method
Marks a user as blocked so that they can't log in, and invalidates the cache for the user, and signs the user out.
Implementation
static Future<void> blockUser(
Session session,
int userId,
) async {
var userInfo = await findUserByUserId(session, userId);
if (userInfo == null) {
throw 'userId $userId not found';
} else if (userInfo.blocked) {
throw 'userId $userId already blocked';
}
// Mark user as blocked in database
userInfo.blocked = true;
await session.db.updateRow(userInfo);
await invalidateCacheForUser(session, userId);
// Sign out user
await UserAuthentication.signOutUser(session, userId: userId);
}