I am using HttpServletRequest to authentify user .
The probleme is that many users can login with same account in the sametime. I want to detect when a new user is trying to connect with an account that is already connected .so the application give him two possibilities to leave or force authentification so automaticly the first session opened will be closed .
how can i do that ??
thats my code
public String Login() {
try {
message="";
Date datehistorique = new Date();
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
request.login(username, password);
if(request.isUserInRole("Administrateur"))
{ setGroupname("Administrateur");
return "/profil/admin/adminHome.xhtml?faces-redirect=true";}
else {
message= "Either Login or Password is wrong";
return "/index.xhtml";
}
} catch(Exception e) {
message= "Either Login or Password is wrong";
this.groupname="";
this.username="";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Votre Nom utilisateur ou votre Mot de passe est incorrect.", ""));
}
return null;
}
Aucun commentaire:
Enregistrer un commentaire