setCredentials method

Future<Either<String, dynamic>> setCredentials({
  1. required String user,
  2. required String password,
  3. required int clientIdentifier,
})

Sets the credentials on the native platform using the provided user, password, and clientIdentifier.

Returns an Either containing an error message on the left or the response on the right.

Implementation

Future<Either<String, dynamic>> setCredentials({
  required String user,
  required String password,
  required int clientIdentifier,
}) async {
  final response =
      await invokeNativeMethod('SmartfaceMobile.setCredentials', {
    'arg0': user,
    'arg1': password,
    'arg2': clientIdentifier,
  });

  if (response.isLeft() || !response.asRight) {
    return response;
  }

  await _secureStorageWrite(key: 'user', value: user);
  await _secureStorageWrite(key: 'password', value: password);
  await _secureStorageWrite(
    key: 'clientIdentifier',
    value: clientIdentifier.toString(),
  );
  return response;
}