authorizeEmailPassword method

Future authorizeEmailPassword (
  1. String email,
  2. String password
)

Authorizes the user with email and password. In the body you will find the session token. @param email The email of the user @param password The password of the user @returns If it was successful, it will provide the session token in the body. Save it somewhere safe on the client.

Implementation

dynamic authorizeEmailPassword(String email, String password) 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 an unhashed password as the second parameter.", sCNotifyTypes.ERROR);
  }

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

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

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