Commit 8d7ac397 by Tuomas Riihimäki

Add email passwordchange, some menuchanges

1 parent 6ca7924f
......@@ -79,7 +79,7 @@ public class MenuBean implements MenuBeanLocal {
usermenu.addPage(menuitemfacade.findOrCreate("/permissionDenied"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/auth/login"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/auth/loginError"), null).setVisible(false);
// usermenu.addPage(menuitemfacade.findOrCreate("/auth/logout"), null).setVisible(false); // disabled
// usermenu.addPage(menuitemfacade.findOrCreate("/auth/logout"), null).setVisible(false); // disabled
usermenu.addPage(menuitemfacade.findOrCreate("/auth/logoutResponse"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/auth/resetPassword"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/auth/resetmailSent"), null).setVisible(false);
......@@ -87,7 +87,7 @@ public class MenuBean implements MenuBeanLocal {
usermenu.addPage(menuitemfacade.findOrCreate("/auth/notauthorized"), null).setVisible(false);
MenuNavigation userEvent = usermenu.addPage(null, null);
userEvent.setKey("topnavi.userevent");
userEvent.setKey("topnavi.userevent");
userEvent.addPage(menuitemfacade.findOrCreate("/poll/index"), PollPermission.ANSWER);
userEvent.addPage(menuitemfacade.findOrCreate("/user/invite"), UserPermission.INVITE_USERS);
userEvent.addPage(menuitemfacade.findOrCreate("/feedback/index"), UserPermission.VITUTTAAKO);
......@@ -103,8 +103,7 @@ public class MenuBean implements MenuBeanLocal {
userPlaces.setKey("topnavi.userplaces");
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,10 +115,10 @@ 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);
/*
* MenuNavigation createuser = usermenu.addPage(null, null);
* createuser.setKey("topnavi.createuser");
......@@ -129,21 +128,20 @@ public class MenuBean implements MenuBeanLocal {
navifacade.create(usermenu);
//
// Admin menu
//
MenuNavigation adminmenu = new MenuNavigation(ev, "topmenu.admin", menusort = +10);
//user management
MenuNavigation adminuser = adminmenu.addPage(null, null);
adminuser.setKey("topnavi.usermgmt");
adminuser.setKey("topnavi.usermgmt");
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/list"), UserPermission.VIEW_ALL);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/create"), UserPermission.VIEW_ALL);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/edit"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/changePassword"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/accountEvents"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/accountEvents"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/foodwaveshop"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/foodwaveProducts"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/showTakePicture"), UserPermission.VIEW_ALL).setVisible(false);
......@@ -155,7 +153,7 @@ public class MenuBean implements MenuBeanLocal {
adminroles.addPage(menuitemfacade.findOrCreate("/role/edit"), null).setVisible(false);
adminroles.addPage(menuitemfacade.findOrCreate("/orgrole/list"), UserPermission.READ_ORGROLES);
adminroles.addPage(menuitemfacade.findOrCreate("/orgrole/create"), UserPermission.WRITE_ORGROLES);
MenuNavigation adminEventCards = adminuser.addPage(null, null);
adminEventCards.setKey("subnavi.cards");
adminEventCards.addPage(menuitemfacade.findOrCreate("/useradmin/listCardTemplates"), UserPermission.READ_ROLES);
......@@ -163,11 +161,11 @@ public class MenuBean implements MenuBeanLocal {
adminEventCards.addPage(menuitemfacade.findOrCreate("/useradmin/editCardTemplate"), null).setVisible(false);
adminEventCards.addPage(menuitemfacade.findOrCreate("/shop/shopToUser"), null).setVisible(false);
adminEventCards.addPage(menuitemfacade.findOrCreate("/shop/assocToUser"), null).setVisible(false);
// shop
MenuNavigation adminshop = adminmenu.addPage(null, null);
adminshop.setKey("topnavi.adminshop");
MenuNavigation adminShopProducts = adminshop.addPage(null, null);
adminShopProducts.setKey("subnavi.products");
adminShopProducts.addPage(menuitemfacade.findOrCreate("/product/create"), ShopPermission.MANAGE_PRODUCTS);
......@@ -181,7 +179,7 @@ public class MenuBean implements MenuBeanLocal {
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/listTemplates"), ShopPermission.MANAGE_FOODWAVES);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/createTemplate"), ShopPermission.MANAGE_FOODWAVES);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/editTemplate"), ShopPermission.MANAGE_FOODWAVES).setVisible(false);
MenuNavigation adminShopReaders = adminshop.addPage(null, null);
adminShopReaders.setKey("subnavi.readers");
adminShopReaders.addPage(menuitemfacade.findOrCreate("/shop/showReaderEvents"), ShopPermission.SHOP_TO_OTHERS);
......@@ -197,18 +195,17 @@ public class MenuBean implements MenuBeanLocal {
adminPlaces.setKey("topnavi.userplaces");
adminPlaces.addPage(menuitemfacade.findOrCreate("/place/adminPlacemap"), UserPermission.VIEW_ALL);
// adminPlaces.addPage(menuitemfacade.findOrCreate("/place/adminGroups"), UserPermission.VIEW_ALL); // todo: make new view for managing
MenuNavigation mapnavi = adminPlaces.addPage(null, null);
mapnavi.setKey("topnavi.maps");
mapnavi.addPage(menuitemfacade.findOrCreate("/map/create"), MapPermission.MANAGE_MAPS);
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");
MenuNavigation contentnavi = adminevent.addPage(null, null);
contentnavi.setKey("topnavi.contents");
contentnavi.addPage(menuitemfacade.findOrCreate("/pages/list"), ContentPermission.MANAGE_PAGES);
......@@ -219,23 +216,18 @@ public class MenuBean implements MenuBeanLocal {
lognavi.setKey("topnavi.log");
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/messagelist"), UserPermission.VIEW_ALL);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), UserPermission.VIEW_ALL).setVisible(false);
MenuNavigation compoMenu = adminevent.addPage(null, null);
compoMenu.setKey("topnavi.compos");
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);
......@@ -335,7 +327,6 @@ public class MenuBean implements MenuBeanLocal {
userTopnavi.addPage(menuitemfacade.findOrCreate("/user/accountEvents"), UserPermission.VIEW_SELF);
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");
......@@ -368,11 +359,10 @@ public class MenuBean implements MenuBeanLocal {
// ShopPermission.SHOP_FOODWAVE);
foodwaveTopmenu.addPage(menuitemfacade.findOrCreate("/foodwave/listProducts"), ShopPermission.SHOP_FOODWAVE).setVisible(false);
foodwaveTopmenu.addPage(menuitemfacade.findOrCreate("/foodwave/ThanksForOrderingFromCounter"), ShopPermission.SHOP_FOODWAVE).setVisible(false);
MenuNavigation gameTopmenu = usernavi.addPage(null, null);
gameTopmenu.setKey("topnavi.license");
gameTopmenu.addPage(menuitemfacade.findOrCreate("/license/viewCodes"), LicensePermission.VIEW_OWN_CODES);
MenuNavigation pollTopmenu = usernavi.addPage(null, null);
pollTopmenu.setKey("topnavi.poll");
......
......@@ -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);
......@@ -646,7 +659,7 @@ public class UserBean implements UserBeanLocal {
public List<Feedback> getFeedbacks() {
return feedbackFacade.findAll();
}
@Override
public UserApproval setUserApproval(EventUser user, String approvalName, boolean approvalValue, String notes) {
Approval approval = approvalFacade.findOrCreate(approvalName);
......
......@@ -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
*
......@@ -84,9 +82,13 @@ public interface UserBeanLocal {
SearchResult<EventUser> getThisEventsUsers(UserSearchQuery searchQuery);
void submitFeedback(String feedback);
List<Feedback> getFeedbacks();
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;
......@@ -74,7 +75,7 @@ public class MapManageView extends GenericCDIView {
private String namebase;
private Integer mapId;
private List<Product> productlist;
private StreamedContent streamedFile;
private LanEvent copyEvent;
......@@ -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,14 +360,12 @@ public class MapManageView extends GenericCDIView {
public void setBgFile(UploadedFile bgFile) {
this.bgFile = bgFile;
}
//StreamedContent new DefaultStreamedContent(pdfstream)
public StreamedContent getStreamedFile() {
//DefaultStreamedContent(new ByteArrayInputStream(placebean.generatePlacesPdf(54, 17, 10, 6)));
//DefaultStreamedContent(new ByteArrayInputStream(placebean.generatePlacesPdf(54, 17, 10, 6)));
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,11 +25,12 @@ 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;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(PasswordResetView.class);
......@@ -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())) {
return "/auth/resetmailSent";
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!