You've already forked focalboard
mirror of
https://github.com/mattermost/focalboard.git
synced 2025-07-12 23:50:27 +02:00
More work on auth
This commit is contained in:
@ -8,7 +8,9 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-octo-tasks/server/model"
|
||||
"github.com/mattermost/mattermost-octo-tasks/server/services/auth"
|
||||
)
|
||||
|
||||
@ -109,6 +111,20 @@ func (a *API) handleRegister(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (a *API) sessionRequired(handler func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if a.singleUser {
|
||||
now := time.Now().Unix()
|
||||
session := &model.Session{
|
||||
ID: "single-user",
|
||||
Token: "single-user",
|
||||
UserID: "single-user",
|
||||
CreateAt: now,
|
||||
UpdateAt: now,
|
||||
}
|
||||
ctx := context.WithValue(r.Context(), "session", session)
|
||||
handler(w, r.WithContext(ctx))
|
||||
return
|
||||
}
|
||||
|
||||
token, _ := auth.ParseAuthTokenFromRequest(r)
|
||||
session, err := a.app().GetSession(token)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user