diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-06 20:44:21 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-06 20:44:21 +0800 |
commit | 5614adc762adc2e94a9bf2d6d69fef46570ae376 (patch) | |
tree | 9632a94c7c97e50f87cd87310010813fade11a04 /http_server.go | |
parent | group/index: Reuse ID from first SQL query to avoid triple recursion (diff) | |
download | forge-5614adc762adc2e94a9bf2d6d69fef46570ae376.tar.gz forge-5614adc762adc2e94a9bf2d6d69fef46570ae376.tar.zst forge-5614adc762adc2e94a9bf2d6d69fef46570ae376.zip |
http: Check for direct user access
Diffstat (limited to 'http_server.go')
-rw-r--r-- | http_server.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/http_server.go b/http_server.go index 199a3c5..0dc324d 100644 --- a/http_server.go +++ b/http_server.go @@ -56,6 +56,7 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { params["global"] = global_data var _user_id int // 0 for none _user_id, params["username"], err = get_user_info_from_request(r) + params["user_id"] = _user_id if errors.Is(err, http.ErrNoCookie) { } else if errors.Is(err, pgx.ErrNoRows) { } else if err != nil { @@ -64,9 +65,9 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if _user_id == 0 { - params["user_id"] = "" + params["user_id_string"] = "" } else { - params["user_id"] = strconv.Itoa(_user_id) + params["user_id_string"] = strconv.Itoa(_user_id) } if segments[0] == ":" { |