Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Commit

Permalink
Change Info (still work in progress...) måste fixa passwordvalidatorn...
Browse files Browse the repository at this point in the history
  • Loading branch information
juliar committed Oct 23, 2012
1 parent 4cd2865 commit 83ae600
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 14 deletions.
44 changes: 40 additions & 4 deletions src/main/java/dat076/frukostklubben/bb/ChangeInfoBB.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public class ChangeInfoBB implements Serializable {
UserEJB userRegistry;
private User user;
private String currentMail;
private Boolean selected = false;
private String checkPasswd;

//Attributes that can be changed
private String newPasswd;


// ======================================
// = Public Methods =
Expand All @@ -42,14 +48,17 @@ public String fetchUser() {
}

public void change() {
userRegistry.updateUser(user);
if (checkPasswd.equals(user.getPasswd())) {
user.setPasswd(newPasswd);
userRegistry.updateUser(user);
} else {
checkPasswd = "";
}
}


private String input1;
private String input2;
private boolean input1Set;

public void pwValidator(FacesContext context, UIComponent component,
Object value) {
if (input1Set) {
Expand Down Expand Up @@ -88,4 +97,31 @@ public String getCurrentMail() {
public void setCurrentMail(String currentMail) {
this.currentMail = currentMail;
}

//For checkbox
public Boolean getSelected() {
return selected;
}

public void setSelected(Boolean selected) {
this.selected = selected;
}

//For checking the password
public String getCheckPasswd() {
return checkPasswd;
}

public void setCheckPasswd(String checkPasswd) {
this.checkPasswd = checkPasswd;
}

//Attributes that can be changed
public String getNewPasswd() {
return newPasswd;
}

public void setNewPasswd(String newPasswd) {
this.newPasswd = newPasswd;
}
}
9 changes: 9 additions & 0 deletions src/main/webapp/resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ nav#main_menu{
border: 1px solid rgba(0,0,0,0.75);
}

.inputForm:disabled{
padding: 4px 6px;
font-size: 12px;
width: 250px;
border-radius: 0.5em;
background-color: #7e7e7e;
border: 1px solid rgba(0,0,0,0.75);
}

label{
text-transform:uppercase;
font-size: 12px;
Expand Down
35 changes: 25 additions & 10 deletions src/main/webapp/users/changeInfo.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:f="http://java.sun.com/jsf/core">
xmlns:f="http://java.sun.com/jsf/core"
xmlns:icecore="http://www.icefaces.org/icefaces/core">
<h:body>
<ui:composition template="/jsf/template/template.xhtml">
<ui:define name="content">
Expand Down Expand Up @@ -55,21 +56,35 @@
required="true" requiredMessage=" - required"/>
<h:message for="city" class="error" /></p>

<h2><br/>Change password:</h2>

<p><h:outputLabel for="password" value="Type new Password: " /><br />
<h:inputSecret id="password" value="#{changeInfo.user.passwd}" class="inputForm"
required="true" requiredMessage=" - required"/>
<h:panelGrid columns="2">
<h3><br/>Change password </h3>
<ace:checkboxButton id="changePasswdCheckBox" value="#{changeInfo.selected}">
<ace:ajax execute="@this" event="activate" render="newPassword passwdConfirm"/>
</ace:checkboxButton>
</h:panelGrid>


<p><h:outputLabel for="newPassword" value="Type new Password: " /><br />
<h:inputSecret id="newPassword" value="#{changeInfo.newPasswd}" class="inputForm"
required="true" requiredMessage=" - required" disabled="#{!changeInfo.selected}"/>
<h:message for="city" class="error" /></p>

<p><h:outputLabel for="passwdConfirm" value="Confirm new Password*:" /><br />
<h:inputSecret id="passwdConfirm" size="10" class="inputForm" required="true" requiredMessage=" - required" validator="#{changeInfo.pwValidator}">
<h:inputSecret id="passwdConfirm" size="10" class="inputForm"
required="true" requiredMessage=" - required" validator="#{changeInfo.pwValidator}" disabled="#{!changeInfo.selected}">

</h:inputSecret>
<h:message for="passwdConfirm" id="passwdConfirmError" class="error"/></p>
<h:message for="passwdConfirm" id="passwdConfirmError" class="error"/></p>


<h3><br/>Verify with current Password:</h3>
<p><h:outputLabel for="password" value="Password: " /><br />
<h:inputText id="password" value="#{changeInfo.checkPasswd}" class="inputForm"
required="true" requiredMessage=" - required"/>
<h:message for="password" class="error" /></p>


<h2><br/>Current password:</h2>


<footer><h:commandButton id="register" value="Save Changes" class="inputButton" action="#{changeInfo.change}" />
<h:button outcome="changeInfo" value="Cancel" class="inputButton" /></footer>
</h:form>
Expand Down

0 comments on commit 83ae600

Please sign in to comment.