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/ target/
.settings/
*~ *~

@ -19,4 +19,4 @@ spring.jpa.database-platform=org.sqlite.hibernate.dialect.SQLiteDialect
#spring.jpa.show-sql: true #spring.jpa.show-sql: true
# My special properties # 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 // require all requests to be authenticated except
// for the resources // for the resources
http.authorizeRequests() http.authorizeRequests()
.antMatchers("/javax.faces.resource/**", "/main.jsf", .antMatchers("/javax.faces.resource/**",
"/img/**", "/recipeDetails.jsf") "/",
"/index.jsf",
"/main.jsf",
"/img/**",
"/recipeDetails.jsf",
"/recipePrint.jsf")
.permitAll().anyRequest().authenticated(); .permitAll().anyRequest().authenticated();
// login // login
http.formLogin()// .loginPage("/login.xhtml") http.formLogin()// .loginPage("/login.xhtml")

@ -204,9 +204,14 @@ public class UserSession implements Serializable {
public String logoutAction() { public String logoutAction() {
log.warn("Session Idle listener logout"); 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() { public List<Recipe> getShoppingList() {
return this.shoppingList ; 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> <name>GourmetJ</name>
<navigation-rule> <navigation-rule>
<description>Global Navigation</description>
<display-name>Navigation</display-name>
<from-view-id>/*</from-view-id> <from-view-id>/*</from-view-id>
<navigation-case> <navigation-case>
<description>Go Home</description>
<from-outcome>home</from-outcome> <from-outcome>home</from-outcome>
<to-view-id>main.jsf</to-view-id> <to-view-id>/main.xhtml</to-view-id>
<redirect/> <redirect/>
</navigation-case> </navigation-case>
</navigation-rule> </navigation-rule>

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

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

Loading…
Cancel
Save