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

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Others
    • Labels:
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Pull Master Branch:

      Description

      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 Juan Leyva, Frédéric Massart?

        Attachments

          Activity

            People

            Assignee:
            dpalou Dani Palou
            Reporter:
            dpalou Dani Palou
            Peer reviewer:
            Frédéric Massart Frédéric Massart
            Integrator:
            Juan Leyva Juan Leyva
            Tester:
            Juan Leyva Juan Leyva
            Participants:
            Component watchers:
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              31/Jul/15