Think we need to go back to basics here. A lot of confusion seems to have resulted for the mention of mobile and I understand this is NOT a mobile app, it is a responsive web app.
If so the platform on which it is running should be irrelevant as the api actions run at server level
So this is a PHP web app but for some reason doesnât seem to be logging out when viewed on a mobile device but does on a desktop?
I assume to api action is as at the top of this post, simple logout and remove a session.
How are you calling the logout action?
If this is a PWA they are prone to caching everything. You need to clear this cache on exit. Plenty of documentation and solutions on this revealed in a quick search of Stack Overflow or the web.
Add the following to the end of your service-worker.js file
self.addEventListener('activate', function(event) {
event.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.filter(function(cacheName) {
// Return true if you want to remove this cache,
// but remember that caches are shared across
// the whole origin
}).map(function(cacheName) {
return caches.delete(cacheName);
})
);
})
);
});
Indeed, the API that queries the avatar, name etc⌠is being re-run after logout and logically returns this then:
If I insert a security restrict here, the whole menu with login/logout links disappears.
OK so the userid, redirect etc. are returning null which suggests the logout is working - if you add the Security Restrict step I guess you see an âForbiddenâ response to the API call in dev tools?
In terms of understanding more about the specifics on mobile:
Do you have a service worker on the page? (see @Dave 's point about caching above)
Do you have the PWA installed as an app on the device? or is this when using the devices browser?
Which browser/device are you using?
Does the page reload after logout? Do you redirect to another page?
When you say the menu has the name/avatar etc. what happens if you reload the page?
Have you republished the project once the changes have been made?
check you dont have caching set for your server action
You say the logout is called form the menu - how have you coded that? Is the action called directly from the sub-menu link and if so how have you coded that that.
The steps thing was removed as it wasnât needed after the workflows redesign I believe unless it was brought back for some reason Iâm currently on 4.4.1 (but assume itâs still the same in 4.4.5)
Did you try executing the api in your phone device?
[Right click in your api step (logout), open in browser, and catch the link for running in your phone]
This can dismiss a server side problem.
Did you try the incognito mode? Because maybe is something in the cookies of the session making troubles
I have had issues in the past doing that way if i recall correctly, perhaps a timing issue.
Try converting the click event to a flow to make it run asynchronously.
Also, as to the logic (if i follow correctly) . If logout removes the user data how can you expect it appear in the success event?
success('See you soon '+userIdentity.data.qryNameRolePic.firstname)'##
Also I assume you have a server action to load the current users details on the page.
In the success event of the logout action, perform a userIndentity.load() (correct connection name where appropriate) to force a refresh the data related to the current user
@franse Yes I just tried that, and the response on desktop and on mobile browser is the same:
{"userid":null,"redirect":null}
So it seems the mobile browsers and the desktop do reset the userid to 0
@Hyperbytes You're right, converting to a flow and adding a small Wait (1000ms) between the logout API call and the redirect to /home/ allowed the userid to be reset, and the homepage then is in loggedout state.
That is not really a solution.
It's just not correct to have the logout and redirect at the same dynamic event. The correct way is to run the logout server action on click and then add the redirect on logout server action dynamic events > success. This way the redirect will be called only after logout action has finished.
When you run two dynamic actions on the same event (on click for example) they run at the same time / simultaneously, so in your case the redirect executes before the logout finishes.
Create a logout page
On the page and add a message âAre you sure you with to log out?â and a logout button linked to the logout action and the redirect on success()