+ register
+ logout Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
parent
c091084584
commit
c8b6376284
@ -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 "";
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<title>Internet Technologien</title>
|
||||
</head>
|
||||
<body>
|
||||
<ul>
|
||||
<li><a href="preview">Grobspezifikation</a></li>
|
||||
<li><a href="booklist">Backend</a></li>
|
||||
<li><a href="categories.jsp">Kategorienübersicht</a></li>
|
||||
<li><a href="category.jsf">Warengruppe ausgeben</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
19
src/main/webapp/index.xhtml
Normal file
19
src/main/webapp/index.xhtml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<f:view>
|
||||
|
||||
<ui:composition template="template.xhtml">
|
||||
<ui:define name="content">
|
||||
|
||||
Hallo Welt!!!
|
||||
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
|
||||
</f:view>
|
||||
</html>
|
@ -10,7 +10,7 @@
|
||||
|
||||
<ui:define name="content">
|
||||
|
||||
<h:panelGroup layout="block" styleClass="row" rendered="#{not userBean.correctPassword}">
|
||||
<h:panelGroup layout="block" styleClass="row" rendered="#{userBean.error}">
|
||||
<aside class="m-col-s-3 m-push-l-4 m-note m-danger">
|
||||
<h3>Passwort oder Benutzername falsch</h3>
|
||||
</aside>
|
||||
@ -23,11 +23,14 @@
|
||||
<br/>
|
||||
<h:inputSecret id="password" value="#{userBean.password}">Passwort</h:inputSecret>
|
||||
|
||||
<h:commandButton action="#{userBean.login}">Login</h:commandButton>
|
||||
<h:commandButton action="#{userBean.login}" value="Login"/>
|
||||
</h:form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="register.xhtml">Noch kein Account ?</a>
|
||||
|
||||
|
||||
|
||||
</ui:define>
|
||||
|
||||
|
19
src/main/webapp/logout.xhtml
Normal file
19
src/main/webapp/logout.xhtml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<f:view>
|
||||
|
||||
<ui:composition template="template.xhtml">
|
||||
<ui:define name="content">
|
||||
Sind Sie sich sicher ?
|
||||
<h:commandButton value="ja" action="#{userBean.logout}"/>
|
||||
<h:commandButton value="nein" action="index"/>
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
|
||||
</f:view>
|
||||
</html>
|
29
src/main/webapp/register.xhtml
Normal file
29
src/main/webapp/register.xhtml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<f:view>
|
||||
<ui:composition template="template.xhtml">
|
||||
<ui:define name="content">
|
||||
|
||||
<div class="m-row">
|
||||
<div class="m-col-l-6 m-push-l-4">
|
||||
<h:form>
|
||||
<h:inputText id="username" value="#{userBean.username}">Nutzername</h:inputText>
|
||||
<br/>
|
||||
<h:inputText id="email" value="#{userBean.email}">Email</h:inputText>
|
||||
<br/>
|
||||
<h:inputSecret id="password" value="#{userBean.password}">Passwort</h:inputSecret>
|
||||
|
||||
<h:commandButton action="#{userBean.register}" value="registrieren"/>
|
||||
</h:form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
</f:view>
|
||||
</html>
|
@ -37,19 +37,30 @@
|
||||
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
|
||||
<div class="m-row">
|
||||
<ol class="m-col-t-6 m-col-m-none">
|
||||
<li><a href="category.jsf">Katalog</a></li>
|
||||
<li><a href="category.xhtml">Katalog</a></li>
|
||||
<li><a href="#">(1) Warenkorb</a></li>
|
||||
</ol>
|
||||
<h:panelGroup layout="block" rendered="#{userBean.loggedIn}">
|
||||
<ol class="m-col-t-6 m-col-m-none" start="4">
|
||||
<li>
|
||||
<a href="#">Mein Account</a>
|
||||
<a href="#">#{userBean.user.name}</a>
|
||||
<ol>
|
||||
<li><a href="#">Meine Bestellungen</a></li>
|
||||
<li><a href="#">Adressen und Konten</a></li>
|
||||
<li><a href="#">Abmelden</a></li>
|
||||
<li><a href="orders.xhtml">Meine Bestellungen</a></li>
|
||||
<li><a href="">Adressen und Konten</a></li>
|
||||
<li><a href="logout.xhtml">Abmelden</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</h:panelGroup>
|
||||
<h:panelGroup layout="block" rendered="#{not userBean.loggedIn}">
|
||||
<ol class="m-col-t-6 m-col-m-none" start="4">
|
||||
<li>
|
||||
<a href="login.xhtml">Anmelden</a>
|
||||
|
||||
</li>
|
||||
</ol>
|
||||
</h:panelGroup>
|
||||
|
||||
<ol class="m-col-t-6 m-col-m-none" start="6">
|
||||
<li>
|
||||
<a href="#"><i class="fas fa-ellipsis-v"/></a>
|
||||
|
Loading…
Reference in New Issue
Block a user