-
Sub-task
-
Resolution: Fixed
-
Minor
-
2.0
-
-
MOODLE_20_STABLE
-
MOODLE_20_STABLE
In MM1, when a WS request fails with an error 'invalidtoken' or 'accessexception', the current_site is deleted (logout) and the user is redirected to the login page.
We should implement something like that in MM2 too, otherwise the user will find that all his requests fail. There's a TODO comment in $mmWS.call where those cases should be treated.
Some people use $rootScope to "send events" between services:
$rootScope.$broadcast('myevent', myobject);
|
|
$rootScope.$on('myevent', function(event, myobject) {... //
|
I don't like using $rootScope, so another solution I thought is to implement a $mmEvents service. This service would provide functions to listen (register) and to trigger an event. In $mmWS.call we could do something like $mmEvents.trigger('mm_invalid_session'), and then somewhere else listen for that event to logout the user and redirect to login page.