signUp method
Registers a user on Parse Server
After creating a new user via Parse.create
call this method to register
that user on Parse
By setting allowWithoutEmail
to true
, you can sign up without setting an email
Set doNotSendInstallationID
to 'true' in order to prevent the SDK from sending the installationID to the Server.
This option is especially useful if you are running you application on web and you don't have permission to add 'X-Parse-Installation-Id' as an allowed header on your parse-server.
Implementation
Future<ParseResponse> signUp(
{bool allowWithoutEmail = false,
bool doNotSendInstallationID = false}) async {
forgetLocalSession();
try {
if (emailAddress == null) {
if (!allowWithoutEmail) {
assert(() {
print(
'`ParseUser().signUp()` failed, because the email is not set. If you want to allow signUp without a set email, you should run `ParseUser().signUp(allowWithoutEmail = true)`');
return true;
}());
throw '`signUp` failed, because `emailAddress` of ParseUser was not provided and `allowWithoutEmail` was `false`';
} else {
assert(() {
print(
'It is recommended to only allow user signUp with an email set.');
return true;
}());
}
}
final Uri url = getSanitisedUri(_client, path);
final String body = json.encode(toJson(forApiRQ: true));
_saveChanges();
final String? installationId = await _getInstallationId();
final ParseNetworkResponse response = await _client.post(url.toString(),
options: ParseNetworkOptions(headers: <String, String>{
keyHeaderRevocableSession: '1',
if (installationId != null && !doNotSendInstallationID)
keyHeaderInstallationId: installationId,
}),
data: body);
return await _handleResponse(
this, response, ParseApiRQ.signUp, _debug, parseClassName);
} on Exception catch (e) {
return handleException(e, ParseApiRQ.signUp, _debug, parseClassName);
}
}