changeFullName static method

Future<UserInfo?> changeFullName(
  1. Session session,
  2. int userId,
  3. String newFullName
)

Updates a users name, returns null if unsuccessful.

Implementation

static Future<UserInfo?> changeFullName(
  Session session,
  int userId,
  String newFullName,
) async {
  var userInfo = await findUserByUserId(session, userId, useCache: false);
  if (userInfo == null) return null;

  userInfo.fullName = newFullName;
  await UserInfo.db.updateRow(session, userInfo);

  if (AuthConfig.current.onUserUpdated != null) {
    await AuthConfig.current.onUserUpdated!(session, userInfo);
  }

  await invalidateCacheForUser(session, userId);
  return userInfo;
}