refreshLogin method

Future refreshLogin({
  1. dynamic inputConf,
  2. dynamic inputCredentials,
  3. dynamic scope,
  4. dynamic storeInfo = true,
})

Automatically redo the login

Implementation

Future refreshLogin({
  inputConf,
  inputCredentials,
  scope,
  storeInfo = true,
}) async {
  final conf = inputConf ?? getConfiguration();
  if (conf == null) {
    throw 'Error during kc-refresh-login: '
        'Could not read configuration from storage';
  }

  final credentials = inputCredentials ?? await getCredentials();
  if (credentials == null) {
    throw 'Error during kc-refresh-login:  Could not read from AsyncStorage';
  }

  final username = credentials['username'];
  final password = credentials['password'];

  if (username == null || password == null) {
    throw 'Error during kc-refresh-login: Username or Password not found';
  }

  _performLogin(conf, username, password, scope: scope, storeInfo: storeInfo);
}