signUp static method
POST /auth/sign-up: email, password, optionally name and a bot
challenge token.
Implementation
static Future<Response> signUp(Request request) => _guard(() async {
final DVCredentialGuard? guard = _credentials;
if (guard == null) return _notConfigured();
final _Body body = await _body(request);
final Response? refused = body.refused;
if (refused != null) return refused;
final String? email = body.string('email');
final String? password = body.string('password');
if (email == null || password == null) return _missingCredentials();
final AuthUser? user;
try {
user = await guard.signUp(
email,
password,
name: body.string('name'),
source: sourceOf(request),
challengeToken: body.string('challenge'),
);
} on Object catch (error) {
return _credentialError(error);
}
if (user == null) return _credentialError(AuthException.invalidCredentials);
return _issue(request, user);
});