mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-13 20:28:50 +01:00
🐛 Multiple workspace access authentication error https://github.com/siyuan-note/siyuan/issues/16786
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
0f8bfe0132
commit
549e1faa09
1 changed files with 34 additions and 2 deletions
|
|
@ -587,8 +587,13 @@ func InitConf() {
|
|||
|
||||
Conf.DataIndexState = 0
|
||||
|
||||
if "" == Conf.CookieKey {
|
||||
Conf.CookieKey = gulu.Rand.String(16)
|
||||
if cookieKey := readCookieKey(); "" != cookieKey {
|
||||
Conf.CookieKey = cookieKey
|
||||
} else {
|
||||
if "" == Conf.CookieKey {
|
||||
Conf.CookieKey = gulu.Rand.String(16)
|
||||
}
|
||||
writeCookieKey(Conf.CookieKey)
|
||||
}
|
||||
|
||||
Conf.Save()
|
||||
|
|
@ -600,6 +605,33 @@ func InitConf() {
|
|||
go util.InitTesseract()
|
||||
}
|
||||
|
||||
func readCookieKey() (cookieKey string) {
|
||||
cookieKeyPath := filepath.Join(util.HomeDir, ".config", "siyuan", "cookie.key")
|
||||
if !gulu.File.IsExist(cookieKeyPath) {
|
||||
return
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(cookieKeyPath)
|
||||
if err != nil {
|
||||
logging.LogErrorf("read cookie key file [%s] failed: %s", cookieKeyPath, err)
|
||||
return
|
||||
}
|
||||
|
||||
cookieKey = string(bytes.TrimSpace(data))
|
||||
return
|
||||
}
|
||||
|
||||
func writeCookieKey(cookieKey string) {
|
||||
cookieKeyPath := filepath.Join(util.HomeDir, ".config", "siyuan", "cookie.key")
|
||||
if gulu.File.IsExist(cookieKeyPath) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := os.WriteFile(cookieKeyPath, []byte(cookieKey), 0644); err != nil {
|
||||
logging.LogErrorf("save cookie key file [%s] failed: %s", cookieKeyPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
func initLang() {
|
||||
p := filepath.Join(util.WorkingDir, "appearance", "langs")
|
||||
dir, err := os.Open(p)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue