mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Restructure go project (#2356)
* Move main to cmd * Move api to internal * Move logger and manager to internal * Move shell hiding code to separate package * Decouple job from desktop and utils * Decouple session from config * Move static into internal * Decouple config from dlna * Move desktop to internal * Move dlna to internal * Decouple remaining packages from config * Move config into internal * Move jsonschema and paths to models * Make ffmpeg functions private * Move file utility methods into fsutil package * Move symwalk into fsutil * Move single-use util functions into client package * Move slice functions to separate packages * Add env var to suppress windowsgui arg * Move hash functions into separate package * Move identify to internal * Move autotag to internal * Touch UI when generating backend
This commit is contained in:
@@ -8,8 +8,7 @@ import (
|
||||
"github.com/gorilla/securecookie"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
|
||||
)
|
||||
|
||||
type key int
|
||||
@@ -40,16 +39,16 @@ var ErrUnauthorized = errors.New("unauthorized")
|
||||
|
||||
type Store struct {
|
||||
sessionStore *sessions.CookieStore
|
||||
config *config.Instance
|
||||
config SessionConfig
|
||||
}
|
||||
|
||||
func NewStore(c *config.Instance) *Store {
|
||||
func NewStore(c SessionConfig) *Store {
|
||||
ret := &Store{
|
||||
sessionStore: sessions.NewCookieStore(config.GetInstance().GetSessionStoreKey()),
|
||||
sessionStore: sessions.NewCookieStore(c.GetSessionStoreKey()),
|
||||
config: c,
|
||||
}
|
||||
|
||||
ret.sessionStore.MaxAge(config.GetInstance().GetMaxSessionAge())
|
||||
ret.sessionStore.MaxAge(c.GetMaxSessionAge())
|
||||
|
||||
return ret
|
||||
}
|
||||
@@ -62,7 +61,7 @@ func (s *Store) Login(w http.ResponseWriter, r *http.Request) error {
|
||||
password := r.FormValue(passwordFormKey)
|
||||
|
||||
// authenticate the user
|
||||
if !config.GetInstance().ValidateCredentials(username, password) {
|
||||
if !s.config.ValidateCredentials(username, password) {
|
||||
return ErrInvalidCredentials
|
||||
}
|
||||
|
||||
@@ -165,7 +164,7 @@ func GetVisitedPlugins(ctx context.Context) []string {
|
||||
|
||||
func AddVisitedPlugin(ctx context.Context, pluginID string) context.Context {
|
||||
curVal := GetVisitedPlugins(ctx)
|
||||
curVal = utils.StrAppendUnique(curVal, pluginID)
|
||||
curVal = stringslice.StrAppendUnique(curVal, pluginID)
|
||||
return setVisitedPlugins(ctx, curVal)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user