Commit 8d7ac397 by Tuomas Riihimäki

Add email passwordchange, some menuchanges

1 parent 6ca7924f
......@@ -104,7 +104,6 @@ public class MenuBean implements MenuBeanLocal {
userPlaces.addPage(menuitemfacade.findOrCreate("/place/placemap"), MapPermission.VIEW);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/myGroups"), MapPermission.BUY_PLACES);
MenuNavigation usercompetitions = usermenu.addPage(null, null);
usercompetitions.setKey("topnavi.competitions");
......@@ -116,7 +115,7 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation userprofile = usermenu.addPage(null, null);
userprofile.setKey("topnavi.profile");
userprofile.addPage(menuitemfacade.findOrCreate("/user/edit"), UserPermission.MODIFY);
userprofile.addPage(menuitemfacade.findOrCreate("/user/edit"), UserPermission.VIEW_SELF);
userprofile.addPage(menuitemfacade.findOrCreate("/user/changePassword"), UserPermission.VIEW_SELF);
userprofile.addPage(menuitemfacade.findOrCreate("/auth/logout"), UserPermission.LOGOUT);
......@@ -129,7 +128,6 @@ public class MenuBean implements MenuBeanLocal {
navifacade.create(usermenu);
//
// Admin menu
//
......@@ -204,7 +202,6 @@ public class MenuBean implements MenuBeanLocal {
mapnavi.addPage(menuitemfacade.findOrCreate("/map/list"), MapPermission.MANAGE_MAPS);
mapnavi.addPage(menuitemfacade.findOrCreate("/map/edit"), null).setVisible(false);
// event
MenuNavigation adminevent = adminmenu.addPage(null, null);
adminevent.setKey("topnavi.event");
......@@ -225,17 +222,12 @@ public class MenuBean implements MenuBeanLocal {
compoMenu.addPage(menuitemfacade.findOrCreate("/voting/admincompolist"), CompoPermission.VIEW_COMPOS);
compoMenu.addPage(menuitemfacade.findOrCreate("/voting/create"), CompoPermission.MANAGE);
MenuNavigation gamenavi = adminevent.addPage(null, null);
gamenavi.setKey("topnavi.license");
gamenavi.addPage(menuitemfacade.findOrCreate("/license/manageCodes"), LicensePermission.MANAGE);
adminevent.addPage(menuitemfacade.findOrCreate("/eventorg/list"), EventPermission.MANAGE_PROPERTIES);
navifacade.create(adminmenu);
MenuNavigation shopmenu = new MenuNavigation(ev, "topnavi.shopnavi", menusort = +10);
......@@ -336,7 +328,6 @@ public class MenuBean implements MenuBeanLocal {
userTopnavi.addPage(menuitemfacade.findOrCreate("/place/myGroups"), UserPermission.VIEW_SELF);
userTopnavi.addPage(menuitemfacade.findOrCreate("/user/sendPicture"), UserPermission.VIEW_SELF);
MenuNavigation placemapTopmenu = usernavi.addPage(null, null);
placemapTopmenu.setKey("topnavi.placemap");
placemapTopmenu.addPage(menuitemfacade.findOrCreate("/place/placemap"), MapPermission.VIEW);
......@@ -373,7 +364,6 @@ public class MenuBean implements MenuBeanLocal {
gameTopmenu.setKey("topnavi.license");
gameTopmenu.addPage(menuitemfacade.findOrCreate("/license/viewCodes"), LicensePermission.VIEW_OWN_CODES);
MenuNavigation pollTopmenu = usernavi.addPage(null, null);
pollTopmenu.setKey("topnavi.poll");
pollTopmenu.addPage(menuitemfacade.findOrCreate("/poll/index"), PollPermission.ANSWER);
......
......@@ -523,7 +523,6 @@ public class PlaceBean implements PlaceBeanLocal {
float pagey = height / pointInMillim;
for (Place place : places) {
Page page = new Page(pdf, new float[] { pagex, pagey });
// place code
......
......@@ -358,9 +358,22 @@ public class UserBean implements UserBeanLocal {
}
@Override
public boolean initPasswordReset(String username, String url) {
public boolean initPasswordResetForUsername(String username, String url) {
User user = userFacade.findByLogin(username);
return initPasswordReset(user, url);
}
@Override
public boolean initPasswordResetForEmail(String email, String url) {
List<User> users = userFacade.findByEmail(email);
if (users.size() != 1) {
return false;
}
return initPasswordReset(users.get(0), url);
}
private boolean initPasswordReset(User user, String url)
{
String hash = PasswordFunctions.generateRandomString(25);
logger.info("Initializing password sending: {}, hash: {}", user, hash);
......
......@@ -38,8 +38,6 @@ public interface UserBeanLocal {
boolean resetPassword(User user, String password, String hash);
boolean initPasswordReset(String user, String mailpath);
/**
* Search EventUser entity by User entity ID
*
......@@ -89,4 +87,8 @@ public interface UserBeanLocal {
UserApproval setUserApproval(EventUser user, String approvalName, boolean approvalValue, String notes);
boolean initPasswordResetForEmail(String email, String url);
boolean initPasswordResetForUsername(String username, String url);
}
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:login="http://java.sun.com/jsf/composite/tools/login" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:login="http://java.sun.com/jsf/composite/tools/login" xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<title></title>
</h:head>
......@@ -12,19 +10,34 @@
<ui:composition template="#{sessionHandler.template}">
<ui:define name="content">
<h1><h:outputText value="#{i18n['resetMail.header']}" /></h1>
<p><h:outputText value="#{i18n['resetMail.body']}" /></p>
<h1>
<h:outputText value="#{i18n['resetMail.header']}" />
</h1>
<p>
<h:outputText value="#{i18n['resetMail.body']}" />
</p>
<h:form>
<h:panelGrid columns="3">
<h:outputLabel value="#{i18n['resetMail.username']}:" for="username" />
<h:inputText id="username" value="#{pwdResetView.mailuser}" />
<h:inputText id="username" value="#{pwdResetView.username}" />
<h:message for="username" />
</h:panelGrid>
<h:commandButton id="sendReset" value="#{i18n['resetMail.send']}" action="#{pwdResetView.sendMail()}" />
</h:form>
<h:form>
<h:panelGrid columns="3">
<h:outputLabel value="#{i18n['resetMail.email']}:" for="emailaddr" />
<h:inputText id="emailaddr" value="#{pwdResetView.emailaddr}" />
<h:message for="emailaddr" />
</h:panelGrid>
<h:commandButton id="sendReset" value="#{i18n['resetMail.send']}" action="#{pwdResetView.sendMail()}" />
</h:form>
</ui:define>
</ui:composition>
</h:body>
......
......@@ -30,7 +30,7 @@
</h:form>
<h:form>
<p:commandButton id="downloadLink" value="koodipdf" ajax="false" >
<p:commandButton id="downloadLink" actionListener="mapManageView.generatePlacePdf" value="koodipdf" ajax="false" >
<p:fileDownload value="#{mapManageView.streamedFile}" />
</p:commandButton>
</h:form>
......
......@@ -26,7 +26,7 @@ public class PageOutputView extends GenericCDIView {
public void initIndexView()
{
name = "/index";
name = "/frontpage";
initView();
}
......
package fi.codecrew.moya.web.cdiview.map;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -91,16 +92,27 @@ public class MapManageView extends GenericCDIView {
map = eventmapBean.find(getMapId());
setProductlist(productbean.getProducts());
super.beginConversation();
streamedFile = new DefaultStreamedContent(new ByteArrayInputStream(placebean.generatePlacesPdf(54, 17, 18, 15)),"application/pdf", "paikkakoodit");
}
if (map != null && !map.getPlaces().isEmpty())
streamedFile = new DefaultStreamedContent(new ByteArrayInputStream(placebean.generatePlacesPdf(54, 17, 18, 15)), "application/pdf", "paikkakoodit");
}
}
public String submitBg()
{
map.setMapData(bgFile.getContents());
byte[] bytes = bgFile.getContents();
if (bytes == null && bgFile.getSize() > 0)
{
bytes = new byte[(int) bgFile.getSize()];
try {
bgFile.getInputstream().read(bytes);
} catch (IOException e) {
super.addFaceMessage("mapManage.errorUploadingBackground");
return null;
}
}
map.setMapData(bytes);
map = eventmapBean.saveMap(map);
return null;
}
......@@ -348,6 +360,7 @@ public class MapManageView extends GenericCDIView {
public void setBgFile(UploadedFile bgFile) {
this.bgFile = bgFile;
}
//StreamedContent new DefaultStreamedContent(pdfstream)
public StreamedContent getStreamedFile() {
......@@ -356,6 +369,3 @@ public class MapManageView extends GenericCDIView {
return streamedFile;
}
}
......@@ -110,7 +110,24 @@ public class EventPropertyView extends GenericCDIView {
logger.info("Saving property {}, eventorg {}, key {}", new Object[] { privateProperty.getEvent(), privateProperty.getEventorg(), privateProperty.getKey() });
if (privateProperty.getKey().isData() && file != null)
{
privateProperty.setByteValue(file.getContents());
byte[] contents = null;
if (file.getContents() != null) {
contents = file.getContents();
} else {
contents = new byte[(int) file.getSize()];
try {
file.getInputstream().read(contents);
} catch (IOException e) {
logger.warn("Error reading file from stream", e);
contents = null;
}
}
if (contents == null) {
super.addFaceMessage("eventProperty.errorUploadingFile");
return null;
}
privateProperty.setByteValue(contents);
privateProperty.setByteMime(file.getContentType());
}
privateProperty = eventbean.saveOrCreatePrivateProperty(privateProperty);
......@@ -154,7 +171,7 @@ public class EventPropertyView extends GenericCDIView {
super.addFaceMessage("eventProperty.errorUploadingFile");
return null;
}
property.setByteValue(file.getContents());
property.setByteValue(contents);
property.setByteMime(file.getContentType());
}
property = eventbean.saveOrCreateProperty(property);
......
......@@ -59,7 +59,25 @@ public class CardView extends GenericCDIView {
{
try {
logger.info("Templateimage: {}", getTemplateImage());
cardTemplate = cfbean.saveImage(cardTemplate, getTemplateImage().getContents());
byte[] contents = null;
UploadedFile file = getTemplateImage();
if (file.getContents() != null) {
contents = file.getContents();
} else {
contents = new byte[(int) file.getSize()];
try {
file.getInputstream().read(contents);
} catch (IOException e) {
logger.warn("Error reading file from stream", e);
contents = null;
}
}
if (contents == null) {
super.addFaceMessage("eventProperty.errorUploadingFile");
return null;
}
cardTemplate = cfbean.saveImage(cardTemplate, contents);
} catch (IOException e) {
logger.info("Error converting template image", e);
super.addFaceMessage("template.uploadFailed", e.getMessage());
......
......@@ -25,7 +25,8 @@ public class PasswordResetView extends GenericCDIView {
private String confirm;
private User user;
private String mailuser;
private String username;
private String emailaddr;
@EJB
private transient UserBeanLocal userbean;
......@@ -76,11 +77,19 @@ public class PasswordResetView extends GenericCDIView {
.append(FacesContext.getCurrentInstance().getExternalContext().getContextName())
.append("/auth/resetPassword.jsf?id={0}&hash={1}");
if (userbean.initPasswordReset(mailuser, path.toString())) {
if (username != null && !username.isEmpty())
{
if (userbean.initPasswordResetForUsername(username, path.toString())) {
return "/auth/resetmailSent";
}
} else if (emailaddr != null && !emailaddr.isEmpty()) {
if (userbean.initPasswordResetForUsername(emailaddr, path.toString())) {
return "/auth/resetmailSent";
}
mailuser = null;
}
username = null;
emailaddr = null;
this.addFaceMessage("passwordreset.usernotfound");
return null;
}
......
package fi.codecrew.moya.web.cdiview.voting;
import java.io.IOException;
import java.util.ArrayList;
import javax.ejb.EJB;
......@@ -143,14 +144,35 @@ public class CompoView extends GenericCDIView {
public String submitEntryfile()
{
if (getUploadedFile() == null)
UploadedFile file = getUploadedFile();
if (file == null)
{
super.addFaceMessage("compo.fileuploadFailed");
return null;
}
byte[] contents = null;
if (file.getContents() != null) {
contents = file.getContents();
} else {
contents = new byte[(int) file.getSize()];
try {
file.getInputstream().read(contents);
} catch (IOException e) {
logger.warn("Error reading file from stream", e);
contents = null;
}
}
if (contents == null)
{
super.addFaceMessage("compo.fileuploadFailed");
return null;
}
CompoEntryFile cef = new CompoEntryFile(getEntry());
cef.setFileData(this.getUploadedFile().getContents());
cef.setFileData(contents);
logger.info("Got file name {} length {}", getUploadedFile().getFileName(), cef.getFileData().length);
cef.setFileName(getUploadedFile().getFileName());
cef.setMimeType(getUploadedFile().getContentType());
......
package fi.codecrew.moya.web.cdiview.voting;
import java.io.IOException;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.validation.constraints.NotNull;
import org.primefaces.model.UploadedFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.model.CompoEntry;
import fi.codecrew.moya.model.CompoEntryFile;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class VotingCompoAddEntryView {
public class VotingCompoAddEntryView extends GenericCDIView {
private static final long serialVersionUID = -93065881159476197L;
@EJB
VotingBeanLocal votingBean;
......@@ -29,6 +36,8 @@ public class VotingCompoAddEntryView {
private Integer compoId;
private String compoName;
private static final Logger logger = LoggerFactory.getLogger(VotingCompoAddEntryView.class);
public Integer getCompoId() {
return compoId;
}
......@@ -78,13 +87,41 @@ public class VotingCompoAddEntryView {
}
public String send() {
UploadedFile file = getUploadedFile();
if (file == null)
{
super.addFaceMessage("compo.fileuploadFailed");
return null;
}
byte[] contents = null;
if (file.getContents() != null) {
contents = file.getContents();
} else {
contents = new byte[(int) file.getSize()];
try {
file.getInputstream().read(contents);
} catch (IOException e) {
logger.warn("Error reading file from stream", e);
contents = null;
}
}
if (contents == null)
{
super.addFaceMessage("compo.fileuploadFailed");
return null;
}
CompoEntry compoEntry = new CompoEntry();
compoEntry.setTitle(name);
compoEntry.setNotes(notes);
compoEntry.setScreenMessage(screenMessage);
compoEntry.setCompo(votingBean.getCompoById(compoId));
CompoEntryFile cef = new CompoEntryFile(compoEntry);
cef.setFileData(this.uploadedFile.getContents());
cef.setFileData(contents);
cef.setFileName(uploadedFile.getFileName());
votingBean.addEntry(compoEntry, cef);
return null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!