Prepare for storing last server
parent
813d03a5c7
commit
89644e4702
2
auth.go
2
auth.go
|
@ -25,6 +25,8 @@ type authBackend interface {
|
||||||
Exists(name string) bool
|
Exists(name string) bool
|
||||||
Passwd(name string) (salt, verifier []byte, err error)
|
Passwd(name string) (salt, verifier []byte, err error)
|
||||||
SetPasswd(name string, salt, verifier []byte) error
|
SetPasswd(name string, salt, verifier []byte) error
|
||||||
|
LastSrv(name string) (string, error)
|
||||||
|
SetLastSrv(name, srv string) error
|
||||||
Timestamp(name string) (time.Time, error)
|
Timestamp(name string) (time.Time, error)
|
||||||
Import(in []user)
|
Import(in []user)
|
||||||
Export() ([]user, error)
|
Export() ([]user, error)
|
||||||
|
|
|
@ -52,6 +52,23 @@ func (a authFiles) SetPasswd(name string, salt, verifier []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LastSrv returns the last server a user was on.
|
||||||
|
func (a authFiles) LastSrv(name string) (string, error) {
|
||||||
|
os.Mkdir(Path("auth"), 0700)
|
||||||
|
os.Mkdir(Path("auth/", name), 0700)
|
||||||
|
|
||||||
|
srv, err := os.ReadFile(Path("auth/", name, "/last_server"))
|
||||||
|
return string(srv), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLastSrv sets the last server a user was on.
|
||||||
|
func (a authFiles) SetLastSrv(name, srv string) error {
|
||||||
|
os.Mkdir(Path("auth"), 0700)
|
||||||
|
os.Mkdir(Path("auth/", name), 0700)
|
||||||
|
|
||||||
|
return os.WriteFile(Path("auth/", name, "/last_server"), []byte(srv), 0600)
|
||||||
|
}
|
||||||
|
|
||||||
// Timestamp returns the last time an authentication entry was accessed
|
// Timestamp returns the last time an authentication entry was accessed
|
||||||
// or an error.
|
// or an error.
|
||||||
func (a authFiles) Timestamp(name string) (time.Time, error) {
|
func (a authFiles) Timestamp(name string) (time.Time, error) {
|
||||||
|
|
Loading…
Reference in New Issue