createAnonymousAccount method
Future<AnonymousIdpAccountCreationResult>
createAnonymousAccount(
- Session session, {
- Transaction? transaction,
Creates a new anonymous account.
The optional RateLimit is enforced here if non-null.
Implementation
Future<AnonymousIdpAccountCreationResult> createAnonymousAccount(
final Session session, {
final Transaction? transaction,
}) async {
// Check rate limit and either throw or proceed.
await _rateLimitUtil?.hasTooManyAttempts(
session,
nonce: session.remoteIpAddress.toString(),
);
final newUser = await _authUsers.create(
session,
transaction: transaction,
);
await AnonymousAccount.db.insertRow(
session,
AnonymousAccount(
authUserId: newUser.id,
),
transaction: transaction,
);
await config.onAfterAnonymousAccountCreated?.call(
session,
authUserId: newUser.id,
transaction: transaction,
);
return AnonymousIdpAccountCreationResult._(
authUserId: newUser.id,
scopes: newUser.scopes,
);
}