Welcome page support and security redirections

This commit is contained in:
Tim Holloway 2022-01-18 14:28:47 -05:00
parent 6f0b83aaab
commit 519a9c7e45
8 changed files with 49 additions and 7 deletions

1
.gitignore vendored
View File

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

View File

@ -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

View File

@ -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")

View File

@ -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 ;
} }

View File

@ -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);
}
}

View File

@ -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>

View File

@ -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%;

View File

@ -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>