Hi team,
I’m currently facing an issue where the user token persists on requests made with the Flutter SDK even after logging out the user. We are manually setting the user token and the current user.
We are invoking a custom service, and I have noticed that the issue does not happen if we log in then log out before making any requests. But if we login, make a request, and then log out, the user token is sticky and is still persisted.
Also interesting is that if we call Backendless.userService.getUserToken();
while this issue is happening, it returns null
but when inspecting the network requests the user token is still present.
Please see this sample code that generates the issue:
final tmpUser = BackendlessUser();
tmpUser.setProperty("user-token", "fake-token-1");
tmpUser.setProperty(
"objectId", "3F71DB91-89E9-427B-BD1E-B4E1B4A2BC88");
await Backendless.userService.setCurrentUser(tmpUser);
await Backendless.userService.setUserToken("fake-token-2");
var token = await Backendless.userService.getUserToken();
final valid = await Backendless.userService.isValidLogin();
print("is valid login: ");
print(valid);
await RestaurantService.me(); // custom service request
await Backendless.userService.logout();
var tokenAfterLogin =
await Backendless.userService.getUserToken();
if (tokenAfterLogin != null)
print("tokenAfterLogin is now: " + tokenAfterLogin);
else
print("tokenAfterLogin is null");
See .me()
function definition:
static Future<dynamic> me() {
final parameters = Map();
return Backendless.customService.invoke(_serviceName, "me", parameters);
}
After this code is run, any custom service request has the token attached.
Please advise on how to proceed
Thank you