[Catalyst] Preventing simultaneous logins
Daniel McBrearty
danielmcbrearty at gmail.com
Wed Jul 23 20:47:57 BST 2008
I'm using Cat with a pretty standard configuration of :
Catalyst::Plugin::Authentication
Catalyst::Plugin::Session
Catalyst::Plugin::Session::State::Cookie
Catalyst::Plugin::Session::Store::FastMmap
to handle login and session management. My login code looks like this:
my $u = $params->{username};
if ($c->authenticate( { username => $u,
password => $params->{'password'}
} )){
my $user = $c->user;
$user->last_login(DateTime->now);
$user->update();
$c->response->redirect( $forward, 301);
} else {
# login failed
$c->stash->{login_failed} = 1;
}
What I'd like to do is check if this user is already logged in at some
other computer, and deny access if so. I guess that means :
1. checking whether there is an existing session associated this username
2. Being sure that the associated session is cleared when the user hits 'logout'
I did a quick search and didn't get anything on the list - any quick
clues about the easy way to do this, before I start digging into the
guts of the plugins to see how?
many thanks
Daniel
--
There's an infinite supply of time, we just don't have it all yet.
More information about the Catalyst
mailing list