Uploaded image for project: 'Moodle app'
  1. Moodle app
  2. MOBILE-778 META: Migrate to Ionic
  3. MOBILE-957

$mmWS.call invalidtoken: send an "event" to logout the user

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.0
    • 2.0
    • Others
    • Hide

      To test this the token needs to be invalidated. I know two ways of doing this:

      1. Accessing an instance like school.demo.moodle.net. When the instance is resetted, the token is invalidated.
      2. Use $mmSite.setToken to change the user's token.

      The app should show the reconnect page when a WS request fails with an invalid_token exception. If the user cancels the reconnect, he is redirected to the login page (sites list). If the user reconnects, he'll go back to the page he was before going to the reconnect page.

      Show
      To test this the token needs to be invalidated. I know two ways of doing this: Accessing an instance like school.demo.moodle.net. When the instance is resetted, the token is invalidated. Use $mmSite.setToken to change the user's token. The app should show the reconnect page when a WS request fails with an invalid_token exception. If the user cancels the reconnect, he is redirected to the login page (sites list). If the user reconnects, he'll go back to the page he was before going to the reconnect page.
    • 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.

      What do you think jleyva, fred?

            dpalou Dani Palou
            dpalou Dani Palou
            Frédéric Massart Frédéric Massart
            Juan Leyva Juan Leyva
            Juan Leyva Juan Leyva
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.