diff options
| author | haturatu <taro@eyes4you.org> | 2025-10-13 00:08:25 +0900 |
|---|---|---|
| committer | haturatu <taro@eyes4you.org> | 2025-10-13 00:08:25 +0900 |
| commit | 15830af5b190cfb6f28e0bdf0f4bf110256ed9ef (patch) | |
| tree | efd3c4bdd00f8bea6df8ba2155015d18db5cfba2 /handlers/user.go | |
| parent | 6515a6fd2b2d29a8f363c906148f3abf7cf982e9 (diff) | |
fix(csrf): js csrf support
Diffstat (limited to 'handlers/user.go')
| -rw-r--r-- | handlers/user.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/handlers/user.go b/handlers/user.go index d55f93d..7999755 100644 --- a/handlers/user.go +++ b/handlers/user.go @@ -8,6 +8,8 @@ import ( "auth-proxy/utils" "encoding/json" "net/http" + + "github.com/gorilla/csrf" ) // AccountPageHandler serves the account page, passing user data to the template. @@ -20,8 +22,9 @@ func AccountPageHandler(w http.ResponseWriter, r *http.Request) { } data := map[string]interface{}{ - "Paths": config.Paths, - "User": user, + "Paths": config.Paths, + "User": user, + "CSRFToken": csrf.Token(r), } if err := templates.ExecuteTemplate(w, "account.html", data); err != nil { logging.AppLog.Error("Failed to execute account template", "error", err, "user_id", user.ID) @@ -33,7 +36,8 @@ func ChangePasswordHandler(w http.ResponseWriter, r *http.Request) { // For GET request, just serve the page. if r.Method == http.MethodGet { data := map[string]interface{}{ - "Paths": config.Paths, + "Paths": config.Paths, + "CSRFToken": csrf.Token(r), } if err := templates.ExecuteTemplate(w, "account_password.html", data); err != nil { logging.AppLog.Error("Failed to execute account_password template", "error", err) |
