added user independent sections and started db migration work
This commit is contained in:
parent
6a2dc8146c
commit
16ea95bf09
24 changed files with 622 additions and 122 deletions
|
|
@ -4,10 +4,11 @@ package db
|
|||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"time"
|
||||
)
|
||||
|
||||
var reservedUsers = []string{
|
||||
var reservedNames = []string{
|
||||
"blacklist",
|
||||
"login",
|
||||
"logout",
|
||||
|
|
@ -27,13 +28,18 @@ func hasTrimPrefix(s, prefix string) (string, bool) {
|
|||
return s, false
|
||||
}
|
||||
|
||||
func reservedUser(username string) bool {
|
||||
for _, v := range reservedUsers {
|
||||
if username == v {
|
||||
return true
|
||||
}
|
||||
func addOrRemove(s string, a []string) []string {
|
||||
i, _ := core.Contains(s, a)
|
||||
switch i {
|
||||
case -1:
|
||||
return append(a, s)
|
||||
case 0:
|
||||
return a[1:]
|
||||
case len(a):
|
||||
return a[:i]
|
||||
default:
|
||||
return append(a[:i], a[i+1:]...)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func validatePassword(pw string) (b []byte) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue