add loadUserInfo method;
set automatically call loadUserInfo after login
This commit is contained in:
parent
98f49e07ce
commit
475a6f77cf
@ -20,6 +20,7 @@ public class ProjectBean implements Serializable {
|
||||
private final DatabaseService databaseService = new DatabaseService();
|
||||
private List<Project> projects; // List to store all projects
|
||||
private Project project; // Current project being worked on
|
||||
private UserInfo userInfo; // User info for the current user
|
||||
private String username;
|
||||
private String password;
|
||||
public String projectKeywords = ""; // String to hold project keywords
|
||||
@ -57,6 +58,17 @@ public class ProjectBean implements Serializable {
|
||||
databaseService.close();
|
||||
}
|
||||
|
||||
public void loadUserInfo() {
|
||||
try {
|
||||
UserInfo info = databaseService.getUserInfo(username);
|
||||
if (userInfo != null) {
|
||||
userInfo = info;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadProjects() {
|
||||
projects = databaseService.getProjectsByUser(Objects.requireNonNullElse(username, "admin"));
|
||||
}
|
||||
@ -131,6 +143,7 @@ public class ProjectBean implements Serializable {
|
||||
try {
|
||||
if (databaseService.validateUser(username, password)) {
|
||||
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("username", username);
|
||||
loadUserInfo();
|
||||
loadProjects();
|
||||
return "project";
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user