Skip to content

Commit

Permalink
fix login redirect, add logout html
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Nov 14, 2023
1 parent 0a80031 commit 8787e6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,18 @@ SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Except
}));

return httpSecurity
// login
.formLogin()
.defaultSuccessUrl("/posts/all")
.defaultSuccessUrl("/posts/all", true)
.permitAll()
.and()
// logout // TODO : fix logout redirect
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("classpath:/templates/logout.html") // Redirect to "/logout.html" after logout
.permitAll()
.and()
// auth
.authorizeRequests(auth -> {
auth.anyRequest().authenticated();
})
Expand Down
11 changes: 11 additions & 0 deletions springBootBlog/src/main/resources/templates/logout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LOGOUT PAGE</title>
<h1>LOGOUT PAGE</h1>
</head>
<body>

</body>
</html>

0 comments on commit 8787e6f

Please sign in to comment.