diff --git a/src/main/java/de/hsel/itech/jsf/UserBean.java b/src/main/java/de/hsel/itech/jsf/UserBean.java index 149b4ee..203a2f1 100644 --- a/src/main/java/de/hsel/itech/jsf/UserBean.java +++ b/src/main/java/de/hsel/itech/jsf/UserBean.java @@ -19,6 +19,10 @@ public class UserBean { @Setter private String username; + @Getter + @Setter + private String email; + @Getter @Setter private String password; @@ -27,7 +31,7 @@ public class UserBean { private boolean loggedIn = false; @Getter - private boolean correctPassword = true; + private boolean error = false; public String login() { @@ -35,19 +39,39 @@ public class UserBean { User user = db.user().get(username); if (user == null) { - correctPassword = false; + error = true; return ""; } if (db.user().verify(user, password)) { loggedIn = true; this.user = user; + password = null; + username = null; return "index.xhtml"; } - correctPassword = false; + error = true; return ""; + } + public String logout() { + user = null; + return "index.html"; + } + public String register() { + Database db = Database.getInstance(); + + if(username != null && email != null && password != null) { + User user = new User(email, username, password, (short) 1); + db.user().insert(user); + email = null; + username = null; + password = null; + return "login.xhtml"; + } + + return ""; } } \ No newline at end of file diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html deleted file mode 100644 index 57218fe..0000000 --- a/src/main/webapp/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - -
-