bump copyright, added stats page and updated dependencies
This commit is contained in:
parent
b1028b3d8a
commit
0265d820fe
111 changed files with 9556 additions and 3835 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
// Copyright (C) 2020 Marius Schellenberger
|
||||
|
||||
package db
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,37 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
// Copyright (C) 2020 Marius Schellenberger
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"time"
|
||||
)
|
||||
|
||||
var reservedNames = []string{
|
||||
"blacklist",
|
||||
"login",
|
||||
"logout",
|
||||
"new",
|
||||
"search",
|
||||
"section",
|
||||
"sections",
|
||||
"user",
|
||||
"users",
|
||||
"view",
|
||||
func init() {
|
||||
reservedNames = make([]string, len(reservedURIs))
|
||||
for i, v := range reservedURIs {
|
||||
reservedNames[i] = v[1:]
|
||||
}
|
||||
}
|
||||
|
||||
var reservedURIs = []string{
|
||||
core.LoginURI,
|
||||
core.LogoutURI,
|
||||
core.TotpURI,
|
||||
core.SectionsURI,
|
||||
core.SectionURI,
|
||||
core.SearchURI,
|
||||
core.StatsURI,
|
||||
core.NewURI,
|
||||
core.BlacklistURI,
|
||||
core.UsersURI,
|
||||
core.UserURI,
|
||||
core.ViewURI,
|
||||
}
|
||||
|
||||
var reservedNames []string
|
||||
|
||||
func validatePassword(pw string) (b []byte) {
|
||||
b = []byte(pw)
|
||||
if len(pw) <= 56 {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
// Copyright (C) 2020 Marius Schellenberger
|
||||
|
||||
package db
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
// Copyright (C) 2020 Marius Schellenberger
|
||||
|
||||
package db
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
// Copyright (C) 2020 Marius Schellenberger
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/log"
|
||||
"sort"
|
||||
|
|
@ -62,7 +63,7 @@ func (db *DB) CreateSection(section string, members []string, user bool) error {
|
|||
func (db *DB) UpdateSection(section string, members []string, user bool) error {
|
||||
section = userRe.ReplaceAllString(section, "")
|
||||
if _, ok := core.Contains(section, reservedNames); ok {
|
||||
return errNameReserved
|
||||
return fmt.Errorf("%s: %s", errNameReserved, section)
|
||||
}
|
||||
var m []string
|
||||
if user {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
// Copyright (C) 2020 Marius Schellenberger
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/otp"
|
||||
"git.giftfish.de/ston1th/jwt/v3"
|
||||
|
|
@ -64,7 +65,8 @@ func (db *DB) UserExists(username string) error {
|
|||
func (db *DB) CreateUser(username, password string, admin bool) error {
|
||||
username = userRe.ReplaceAllString(username, "")
|
||||
if _, ok := core.Contains(username, reservedNames); ok {
|
||||
return errNameReserved
|
||||
return fmt.Errorf("%s: %s", errNameReserved, username)
|
||||
|
||||
}
|
||||
if err := db.UserExists(username); err == nil {
|
||||
return errUserExists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue