1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-06 10:00:26 +00:00

Fix auth system not getting enabled

This commit is contained in:
handlerug 2021-04-28 17:12:05 +07:00
parent 3d911fc51b
commit 989ed43455
No known key found for this signature in database
GPG Key ID: 38009F0605051491
3 changed files with 18 additions and 9 deletions

View File

@ -8,7 +8,6 @@ import (
"path/filepath"
"github.com/bouncepaw/mycorrhiza/assets"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
)
@ -55,5 +54,4 @@ func parseCliArgs() {
util.HomePage = util.CanonicalName(util.HomePage)
util.UserHypha = util.CanonicalName(util.UserHypha)
util.HeaderLinksHypha = util.CanonicalName(util.HeaderLinksHypha)
user.AuthUsed = util.UseFixedAuth || util.UseRegistration
}

View File

@ -6,7 +6,6 @@ package main
import (
"fmt"
"github.com/bouncepaw/mycorrhiza/files"
"io/ioutil"
"log"
"math/rand"
@ -15,6 +14,7 @@ import (
"strings"
"github.com/bouncepaw/mycorrhiza/assets"
"github.com/bouncepaw/mycorrhiza/files"
"github.com/bouncepaw/mycorrhiza/history"
"github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/shroom"
@ -193,9 +193,9 @@ func main() {
hyphae.Index(WikiDir)
log.Println("Indexed", hyphae.Count(), "hyphae")
if user.AuthUsed && (util.FixedCredentialsPath != "" || util.RegistrationCredentialsPath != "") {
user.ReadUsersFromFilesystem()
}
// Initialize user database
user.InitUserDatabase()
history.Start(WikiDir)
shroom.SetHeaderLinks()

View File

@ -2,14 +2,25 @@ package user
import (
"encoding/json"
"github.com/bouncepaw/mycorrhiza/files"
"github.com/bouncepaw/mycorrhiza/util"
"io/ioutil"
"log"
"os"
"github.com/bouncepaw/mycorrhiza/files"
"github.com/bouncepaw/mycorrhiza/util"
)
// ReadUsersFromFilesystem reads all user information from filesystem and stores it internally. Call it during initialization.
// InitUserDatabase checks the configuration for auth methods and loads users
// if necessary. Call it during initialization.
func InitUserDatabase() {
AuthUsed = util.UseFixedAuth || util.UseRegistration
if AuthUsed && (util.FixedCredentialsPath != "" || util.RegistrationCredentialsPath != "") {
ReadUsersFromFilesystem()
}
}
// ReadUsersFromFilesystem reads all user information from filesystem and stores it internally.
func ReadUsersFromFilesystem() {
if util.UseFixedAuth {
rememberUsers(usersFromFixedCredentials())