nodeSolidServer/solid-auth-client

Handle multiple logins

Otto-AA opened this issue · 5 comments

Is there a way to handle multiple logins simultaneously?

In my filemanager (this one) this could be used to transfer files between two private pods without the need to download them. For other applications this could be helpful for easily switching between different accounts, or accumulating data from two or more.

And if not, do you know if it would be possible to tweak (a fork of) this package to do this, or if it isn't possible because of server side restrictions?

Is there a way to handle multiple logins simultaneously?

Not yet. There are indeed some use cases where this would be useful.

Ok, thanks for your fast response. Do you mean that it is not possible or just not implemented yet?

If it is latter, I could take a look at it in the next days and try to implement it :)

It's possible, but not implemented yet.

I'd be very happy if you could take a look at it, but I'm pretty sure it will take a substantial effort, given that the interface the library would have to change. I would consider this a major rewrite.

I think the interface itself doesn't need to change much, "only" the underlying code would need to be refactored. I would have thought of wrapping the functionality into a class, which then can be created multiple times. And to keep backwards compatibility a default instance could be created.

So from the users point of view I would propose something like this:

const auth = require('solid-auth-client');

const defaultSession = auth;
const myFirstSession = auth.createNewSession();
const mySecondSession = auth.createNewSession();

await defaultSession.login(idp);
await myFirstSession.login(idp);
await mySecondSession.login(ipd);

await defaultSession.fetch(url, options);
await myFirstSession.fetch(url, options);
// And so on...

I will take a look at it in the next few days and notify you if I manage to get it working or not. I won't start until tomorrow, so if you have any suggestions or tips it would be nice if you could make them in this time span :)

I think the interface itself doesn't need to change much

But…

const myFirstSession = auth.createNewSession();

…that is a substantial interface change 😉

The good thing is that part of the refactoring you need for this already exists, in that solid-auth-client exposes a default instance of a class. So createNewSession would be creating more instances.