onLoginSuccessful method

void onLoginSuccessful(
  1. CtrlMessage? ctrl
)

Implementation

void onLoginSuccessful(CtrlMessage? ctrl) {
  if (ctrl == null) {
    return;
  }

  var params = ctrl.params;
  if (params == null || params['user'] == null) {
    return;
  }

  _userId = params['user'];
  _authenticated = (ctrl.code ?? 0) >= 200 && (ctrl.code ?? 0) < 300;

  if (params['token'] != null && params['expires'] != null) {
    _authToken =
        AuthToken(params['token'], DateTime.parse(params['expires']));
  } else {
    _authToken = null;
  }

  var code = ctrl.code;
  var text = ctrl.text;
  if (code != null && text != null) {
    onLogin.add(OnLoginData(code, text));
  }
}