mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-08-24 07:55:06 +03:00
Update authMiddleware to redirect to main page if no password is set and user accesses login page
This commit is contained in:
parent
2b3b4c39d2
commit
428d29b176
1 changed files with 5 additions and 1 deletions
|
@ -201,8 +201,12 @@ func (w *WebUIServer) cleanupExpiredSessions() {
|
|||
// authMiddleware checks for valid session or redirects to login
|
||||
func (w *WebUIServer) authMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(rw http.ResponseWriter, r *http.Request) {
|
||||
// Skip authentication if no password is set
|
||||
// If no password is set and user tries to access login page, redirect to main page
|
||||
if w.password == "" {
|
||||
if r.URL.Path == "/login.html" {
|
||||
http.Redirect(rw, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
next(rw, r)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue