l10n, create dir on creating file

This commit is contained in:
Wancat
2022-11-04 23:17:17 +08:00
parent 9f99aad680
commit 7c63223aa0
4 changed files with 15 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ import (
)
type AuthStore interface {
Get(user string) bool
Register(user, pass string) error
Login(user, pass string) (token string, err error)
Verify(token string) (session Session, err error)
@@ -39,6 +40,11 @@ func New(path string, hashKey []byte) (AuthStore, error) {
return s, err
}
func (s Htpasswd) Get(user string) bool {
_, ok := s.accounts[user]
return ok
}
func (s Htpasswd) Register(user, pass string) (err error) {
if _, ok := s.accounts[user]; ok {
return errors.New("user already exists")