Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Better way for manage user sessions #195

Closed
iraniamir opened this issue Jan 30, 2018 · 3 comments
Closed

Better way for manage user sessions #195

iraniamir opened this issue Jan 30, 2018 · 3 comments

Comments

@iraniamir
Copy link

i think if we have some changes in code to when user request for login, check this user for active session with same user agent and if have, system dont create new session and reply that active session exist ... github sessions working like that !

@iraniamir iraniamir changed the title Better way fo manage user session Better way fo manage user sessions Jan 30, 2018
@gregfrasco
Copy link
Contributor

I have written code to do that before but didn't make it in.

frame/server/api/login.js

Lines 87 to 108 in 9e5a5b9

assign: 'existingSession',
method: function (request, reply) {
const userAgent = Useragent.lookup(request.headers['user-agent']);
const ip = request.info.remoteAddress;
const browser = userAgent.family;
const os = userAgent.os.toString();
Session.findOne({
userId: request.pre.user._id.toString(),
ip,
browser,
os
}, (err, session) => {
if (err) {
return reply(err);
}
return reply(session);
});
}

@jedireza
Copy link
Owner

jedireza commented Jan 31, 2018

Yeah we should add this. One thing I would add... let's not use the ip as part of the unique identifier for the device. For example my phone is the same browser/session but can be on multiple IPs per day.

@iraniamir iraniamir changed the title Better way fo manage user sessions Better way for manage user sessions Feb 3, 2018
@jedireza
Copy link
Owner

jedireza commented Feb 3, 2018

In the next version of Frame I've simplified session handling a bit. I've removed the revoked property from sessions and also decided (for now) not to include any restoring session logic (this issue) by default.

I intend for Frame to be generic. This results in less opinions forced on other people and also less to maintain. For example; we're using hapi-auth-basic which I don't recommend that anyone use. In 100% of my use cases I remove hapi-auth-basic as almost the first step. In some cases hapi-auth-cookie with keep alive configured has a really good session retention experience for me.

Thanks again for getting involved.

@jedireza jedireza closed this as completed Feb 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants