39 lines
1.2 KiB
Java
39 lines
1.2 KiB
Java
package de.jottyfan.timetrack.modules;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import javax.faces.application.FacesMessage;
|
|
|
|
import org.jooq.exception.DataAccessException;
|
|
|
|
import de.jooqfaces.JooqFacesContext;
|
|
|
|
/**
|
|
*
|
|
* @author henkej
|
|
*
|
|
*/
|
|
public class SessionModel {
|
|
|
|
public boolean doLogin(JooqFacesContext facesContext, SessionBean bean) {
|
|
try {
|
|
return new SessionGateway(facesContext).seekAndSetLogin(bean);
|
|
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
|
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on login", e.getMessage());
|
|
facesContext.addMessage(null, msg);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean doChangePassword(JooqFacesContext facesContext, String secretNew) {
|
|
try {
|
|
SessionBean bean = (SessionBean) facesContext.getExternalContext().getSessionMap().get("sessionBean");
|
|
return new SessionGateway(facesContext).changePassword(bean, secretNew);
|
|
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
|
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on changing password", e.getMessage());
|
|
facesContext.addMessage(null, msg);
|
|
return false;
|
|
}
|
|
}
|
|
}
|