Optimize session retrieval and fix Docker timezone issue

This commit is contained in:
2024-05-02 21:02:50 +07:00
parent 4715814551
commit bb2540a5c4
4 changed files with 41 additions and 26 deletions

View File

@ -59,10 +59,13 @@ func Handler(next http.Handler) http.Handler {
}
func Auth(next http.HandlerFunc, w http.ResponseWriter, r *http.Request) {
status, user := session.GetSession(r)
status, user, sessionID := session.GetSession(r)
switch status {
case session.Authorized:
userSession := session.GetSessionInfo(user.Email, sessionID)
userSession.UpdateAccessTime()
ctx := context.WithValue(r.Context(), "user", user)
req := r.WithContext(ctx)
r.Context().Value("user")
@ -94,7 +97,7 @@ func Auth(next http.HandlerFunc, w http.ResponseWriter, r *http.Request) {
}
func Guest(next http.HandlerFunc, w http.ResponseWriter, r *http.Request) {
status, _ := session.GetSession(r)
status, _, _ := session.GetSession(r)
switch status {
case session.Authorized: