aboutsummaryrefslogtreecommitdiff
path: root/internal/webui/session.go
blob: 58256f29e57bd145ff1ca347bafb16654b1f6c1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package webui

import (
	"net/http"

	"git.adyxax.org/adyxax/trains/pkg/model"
)

func tryAndResumeSession(e *env, r *http.Request) (*model.User, error) {
	cookie, err := r.Cookie(sessionCookieName)
	if err != nil {
		return nil, err
	}
	user, err := e.dbEnv.ResumeSession(cookie.Value)
	if err != nil {
		return nil, err
	}
	return user, nil
}