This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to restrict two user with same username and password

 
Kondal reddy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could any body tell me how can i restrict user from logging in to the server from two machines using same username and password at the same time.
Thanks
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kondal reddy:
Could any body tell me how can i restrict user from logging in to the server from two machines using same username and password at the same time.
Thanks

Just maintain user name and number of sessions in a table, if the username is already associated with a session, disallow other sessions.
 
Sainudheen Mydeen
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this
Write a UserId class implementing HttpSessionBindingListener.
Add a flag column in the user_detail table. When the user login always check the flag.
Allow login only when the flag is "NO". Then set the flag to "YES" and allow login.
Create UserId object add it to the session
valueUnbound method of the UserId class reset the flag (from "YES" to "NO") in the user_detail table.
Sainudheen
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if your webserver crashes? User logged in at the time of the crash will never be able to log in.
Originally posted by Sainudheen Mydeen:
Try this
Write a UserId class implementing HttpSessionBindingListener.
Add a flag column in the user_detail table. When the user login always check the flag.
Allow login only when the flag is "NO". Then set the flag to "YES" and allow login.
Create UserId object add it to the session
valueUnbound method of the UserId class reset the flag (from "YES" to "NO") in the user_detail table.
Sainudheen
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To avoid locking people out forever, clear the table at server startup and make it so nobody is logged on. We have something very similar in a current system. If you have only one instance of your server - no load balanced machines or such things - you might as well manage all of this in memory.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you might as well manage all of this in memory.

This is a good one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic