diff --git a/auth/auth.go b/auth/auth.go index 2760665..04c5222 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -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") diff --git a/templates/signin.html b/templates/signin.html index e9ff082..72b6af0 100644 --- a/templates/signin.html +++ b/templates/signin.html @@ -1,10 +1,11 @@ -{{ define "title" }}Sign Up{{ end }} +{{ define "title" }}登入{{ end }} {{ define "main" }} -

Sign In

+

登入



{{ with .Error }}

{{ . }}

{{ end }} - +
+沒有帳號嗎?註冊 {{ end }} diff --git a/templates/signup.html b/templates/signup.html index a259881..8eed599 100644 --- a/templates/signup.html +++ b/templates/signup.html @@ -1,10 +1,11 @@ -{{ define "title" }}Sign Up{{ end }} +{{ define "title" }}註冊{{ end }} {{ define "main" }} -

Sign Up

+

註冊



{{ with .Error }}

{{ . }}

{{ end }} - +
+已有帳號嗎?登入 {{ end }} diff --git a/user.go b/user.go index 0fa318f..f6f5727 100644 --- a/user.go +++ b/user.go @@ -20,7 +20,7 @@ func (u *User) Dir() string { } func (u *User) FilePath(name string) string { - return path.Join(DATA_DIR, u.Email, name) + return path.Join(u.Dir(), name) } func (u *User) File(name string) (*os.File, error) {