createUser static method
Future<UserInfo?>
createUser(
- Session session,
- UserInfo userInfo, [
- String? authMethod,
- UserInfoCreationCallback? onUserWillBeCreatedOverride,
- UserInfoUpdateCallback? onUserCreatedOverride,
Creates a new user and stores it in the database.
Implementation
static Future<UserInfo?> createUser(
Session session,
UserInfo userInfo, [
String? authMethod,
UserInfoCreationCallback? onUserWillBeCreatedOverride,
UserInfoUpdateCallback? onUserCreatedOverride,
]) async {
bool approved = switch (onUserWillBeCreatedOverride) {
null => await AuthConfig.current.onUserWillBeCreated?.call(
session,
userInfo,
authMethod,
) ??
true,
_ => await onUserWillBeCreatedOverride.call(session, userInfo, authMethod)
};
if (!approved) return null;
userInfo = await UserInfo.db.insertRow(session, userInfo);
if (onUserCreatedOverride == null) {
await AuthConfig.current.onUserCreated?.call(session, userInfo);
} else {
await onUserCreatedOverride(session, userInfo);
}
return userInfo;
}