matrix-js-sdk icon indicating copy to clipboard operation
matrix-js-sdk copied to clipboard

Need an API for logout

Open ara4n opened this issue 9 years ago • 2 comments

Rather than assuming that the app knows to call window.localStorage.clear() or whatever

ara4n avatar Oct 09 '16 18:10 ara4n

The specific concern is around things like mxjssdk_memory_filter_*.

richvdh avatar Oct 09 '16 18:10 richvdh

Currently the loginWithPassword isn't technically a full featured login either -- e.g. my application's login looks like this:

    login(username, password) {
      _login = function () {
          delete client.credentials.userId
          delete client._http.opts.accessToken
          return client.loginWithPassword(username, password).then((result) => {
            client.credentials.userId = result.user_id
            client._http.opts.accessToken  = result.access_token
            this.userId = client.credentials.userId
        }, (error) => {
          console.log(error)
        })
      }.bind(this)
      if (client.credentials.userId) {
        return client.logout().then(_login)
      } else {
        return _login()
      }
    },

To compare the matrix-python-sdk does setup access credentials within the login method rather than requiring to be done manually and in a sense I think that's the better thing to do, if users need login / logout endpoint calls that don't update the client I would suggest leaving _login / _logout for that purpose (it should be a very rare case though).

pik avatar Oct 15 '16 14:10 pik