registerEmailPassword method

Future registerEmailPassword (
  1. String email,
  2. String password,
  3. String language
)

Adds a new user to the authentication system. @param email The new email @param password The new password @param language A two letter language code (ex. de, en) @returns A Response instance, if the request has been finished completed

Implementation

dynamic registerEmailPassword(String email, String password, String language) async {
  if(email == null) {
    throw new sCNotify("Please define an email as the first parameter.", sCNotifyTypes.ERROR);
  }

  if (password == null) {
    throw new sCNotify("Please define a password as the second parameter.", sCNotifyTypes.ERROR);
  }

  if (language == null) {
    new sCNotify("If you want to use localized messages, please provide an language in short form (en, de) as the thrid parameter.", sCNotifyTypes.ERROR);
  }

  var client = new http.Client();
  try {
    Map<String, String> headers = {
      'appid': _app_id,
      'appsecret': _app_secret
    };

    return await client.post(config.api_endpoint + "emailpassword.php",
      headers: headers,
      body: {
        'email': email,
        'password': password,
        'lang': language
      }
    );

  } catch(e) {
    return e;
  } finally {
    client.close();
  }
}