Stack of changes to get gin, scs, nosurf running.
This commit is contained in:
@@ -3,15 +3,12 @@ package security
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
httpHelpers "synlotto-website/internal/helpers/http"
|
||||
"synlotto-website/internal/platform/sessionkeys"
|
||||
|
||||
"github.com/alexedwards/scs/v2"
|
||||
)
|
||||
|
||||
func GetCurrentUserID(r *http.Request) (int, bool) {
|
||||
session, err := httpHelpers.GetSession(nil, r)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
id, ok := session.Values["user_id"].(int)
|
||||
return id, ok
|
||||
func GetCurrentUserID(sm *scs.SessionManager, r *http.Request) (int, bool) {
|
||||
userID := sm.GetInt(r.Context(), sessionkeys.UserID)
|
||||
return userID, userID != 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user