login method
Implementation
Future<Either<ApiError, (String, String)>> login(String email, String password) async {
if (email.isEmpty || password.isEmpty) {
throw Exception("One or more of the field (email, password) is empty");
}
final result = await get(
"$_authRoutesPrefix/login",
(json) => (json["token"].toString(), json["refreshToken"].toString()),
queryParameters: {"email": email, "password": password},
);
if (result.isRight) {
accessToken = result.right.$1;
refreshToken = result.right.$2;
const storage = FlutterSecureStorage();
storage.write(key: "refreshToken", value: refreshToken);
}
return result;
}