mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-22 16:16:51 +00:00
Fix auth system not getting enabled
This commit is contained in:
parent
3d911fc51b
commit
989ed43455
2
flag.go
2
flag.go
@ -8,7 +8,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/bouncepaw/mycorrhiza/assets"
|
"github.com/bouncepaw/mycorrhiza/assets"
|
||||||
"github.com/bouncepaw/mycorrhiza/user"
|
|
||||||
"github.com/bouncepaw/mycorrhiza/util"
|
"github.com/bouncepaw/mycorrhiza/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,5 +54,4 @@ func parseCliArgs() {
|
|||||||
util.HomePage = util.CanonicalName(util.HomePage)
|
util.HomePage = util.CanonicalName(util.HomePage)
|
||||||
util.UserHypha = util.CanonicalName(util.UserHypha)
|
util.UserHypha = util.CanonicalName(util.UserHypha)
|
||||||
util.HeaderLinksHypha = util.CanonicalName(util.HeaderLinksHypha)
|
util.HeaderLinksHypha = util.CanonicalName(util.HeaderLinksHypha)
|
||||||
user.AuthUsed = util.UseFixedAuth || util.UseRegistration
|
|
||||||
}
|
}
|
||||||
|
8
main.go
8
main.go
@ -6,7 +6,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bouncepaw/mycorrhiza/files"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@ -15,6 +14,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bouncepaw/mycorrhiza/assets"
|
"github.com/bouncepaw/mycorrhiza/assets"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/files"
|
||||||
"github.com/bouncepaw/mycorrhiza/history"
|
"github.com/bouncepaw/mycorrhiza/history"
|
||||||
"github.com/bouncepaw/mycorrhiza/hyphae"
|
"github.com/bouncepaw/mycorrhiza/hyphae"
|
||||||
"github.com/bouncepaw/mycorrhiza/shroom"
|
"github.com/bouncepaw/mycorrhiza/shroom"
|
||||||
@ -193,9 +193,9 @@ func main() {
|
|||||||
hyphae.Index(WikiDir)
|
hyphae.Index(WikiDir)
|
||||||
log.Println("Indexed", hyphae.Count(), "hyphae")
|
log.Println("Indexed", hyphae.Count(), "hyphae")
|
||||||
|
|
||||||
if user.AuthUsed && (util.FixedCredentialsPath != "" || util.RegistrationCredentialsPath != "") {
|
// Initialize user database
|
||||||
user.ReadUsersFromFilesystem()
|
user.InitUserDatabase()
|
||||||
}
|
|
||||||
history.Start(WikiDir)
|
history.Start(WikiDir)
|
||||||
shroom.SetHeaderLinks()
|
shroom.SetHeaderLinks()
|
||||||
|
|
||||||
|
@ -2,14 +2,25 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/bouncepaw/mycorrhiza/files"
|
|
||||||
"github.com/bouncepaw/mycorrhiza/util"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"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() {
|
func ReadUsersFromFilesystem() {
|
||||||
if util.UseFixedAuth {
|
if util.UseFixedAuth {
|
||||||
rememberUsers(usersFromFixedCredentials())
|
rememberUsers(usersFromFixedCredentials())
|
||||||
|
Loading…
Reference in New Issue
Block a user