mirror of
https://github.com/hazemKrimi/crimson-vault.git
synced 2026-05-01 18:20:27 +00:00
31 lines
549 B
Go
31 lines
549 B
Go
package lib
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/gorilla/sessions"
|
|
"github.com/hazemKrimi/crimson-vault/internal/types"
|
|
)
|
|
|
|
func GetConfigDirectory() (string, error) {
|
|
home, err := os.UserHomeDir()
|
|
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
config, err := filepath.Abs(filepath.Join(home, DEFAULT_CONFIG_DIRECTORY))
|
|
|
|
return config, nil
|
|
}
|
|
|
|
func ConstructSession(session *sessions.Session, user types.User) {
|
|
session.Options = &sessions.Options{
|
|
Path: "/",
|
|
MaxAge: 86400 * 7,
|
|
HttpOnly: true,
|
|
}
|
|
session.Values["id"] = user.ID
|
|
}
|