registerByUserName static method

Future<AuthResult> registerByUserName(
  1. String username,
  2. String password, {
  3. AuthRequest? authData,
})

register a new user by username and a password.

Implementation

static Future<AuthResult> registerByUserName(String username, String password,
    {AuthRequest? authData}) async {
  var body = jsonEncode({
    'username': username,
    'password': Util.encrypt(password),
    'forceLogin': true
  });
  final Result result = await post('/api/v2/register/username', body);
  AuthResult authResult = AuthResult(result);
  authResult.user = await createUser(result);
  if (authData == null) {
    return authResult;
  } else {
    if (authResult.code == 200) {
      authData.token = authResult.user?.token ?? "";
      return OIDCClient.authByToken(authData.token, authData);
    } else {
      return authResult;
    }
  }
}