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

View File

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

View File

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

View File

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

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

View File

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

View File

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