Welcome page support and security redirections

version2
Tim Holloway 2 years ago
parent 6f0b83aaab
commit 519a9c7e45
  1. 1
      .gitignore
  2. 2
      application.properties
  3. 9
      src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java
  4. 7
      src/main/java/com/mousetech/gourmetj/UserSession.java
  5. 17
      src/main/java/com/mousetech/gourmetj/WelcomePageRedirect.java
  6. 5
      src/main/resources/META-INF/resources/WEB-INF/faces-config.xml
  7. 9
      src/main/resources/META-INF/resources/css/style.css
  8. 6
      src/main/resources/META-INF/resources/recipePrint.xhtml

1
.gitignore vendored

@ -1,3 +1,4 @@
target/
.settings/
*~

@ -19,4 +19,4 @@ spring.jpa.database-platform=org.sqlite.hibernate.dialect.SQLiteDialect
#spring.jpa.show-sql: true
# My special properties
gourmet.password.file=.gourmetpw
gourmet.password.file=${user.home}/.gourmetpw

@ -34,8 +34,13 @@ public class SpringSecurityConfig
// require all requests to be authenticated except
// for the resources
http.authorizeRequests()
.antMatchers("/javax.faces.resource/**", "/main.jsf",
"/img/**", "/recipeDetails.jsf")
.antMatchers("/javax.faces.resource/**",
"/",
"/index.jsf",
"/main.jsf",
"/img/**",
"/recipeDetails.jsf",
"/recipePrint.jsf")
.permitAll().anyRequest().authenticated();
// login
http.formLogin()// .loginPage("/login.xhtml")

@ -204,9 +204,14 @@ public class UserSession implements Serializable {
public String logoutAction() {
log.warn("Session Idle listener logout");
return "/main.jsf";
return goHome();
}
public String goHome() {
log.warn("E.T. Go Home!");
return "/main.jsf?faces-redirect=true";
}
public List<Recipe> getShoppingList() {
return this.shoppingList ;
}

@ -0,0 +1,17 @@
package com.mousetech.gourmetj;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WelcomePageRedirect implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/")
.setViewName("forward:/index.xhtml");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
}

@ -8,10 +8,13 @@
>
<name>GourmetJ</name>
<navigation-rule>
<description>Global Navigation</description>
<display-name>Navigation</display-name>
<from-view-id>/*</from-view-id>
<navigation-case>
<description>Go Home</description>
<from-outcome>home</from-outcome>
<to-view-id>main.jsf</to-view-id>
<to-view-id>/main.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>

@ -22,6 +22,15 @@ textarea {
font-size: 1em
}
@media print {
.noprint {
display: none;
}
.printonly {
display: block;
}
}
#footer {
bottom: 90px;
width: 100%;

@ -23,9 +23,11 @@
style="vertical-align: middle; text-align: left; border: none"
>
<p:commandButton value="Back"
immediate="true" ajax="false"
icon="ui-icon-arrowthick-1-w"
style="margin-left: 2em" immediate="true"
action="/recipeDetails.jsf"
style="margin-left: 2em"
styleClass="noprint"
action="recipeDetails.jsf?faces-redirect=true"
/>
</p:column>
</p:panelGrid>

Loading…
Cancel
Save