diff --git a/cmd/api/v5/user.go b/cmd/api/v5/user.go index e49e9f6..4249552 100755 --- a/cmd/api/v5/user.go +++ b/cmd/api/v5/user.go @@ -2,13 +2,14 @@ package v5 import ( "fmt" + "os" + "strings" + "time" + "github.com/luscis/openlan/cmd/api" "github.com/luscis/openlan/pkg/libol" "github.com/luscis/openlan/pkg/schema" "github.com/urfave/cli/v2" - "os" - "strings" - "time" ) type User struct { @@ -153,7 +154,7 @@ func (u User) Check(c *cli.Context) error { } func (u User) Commands(app *api.App) { - lease := time.Now().AddDate(99, 0, 0) + lease := time.Now().AddDate(1, 0, 0) app.Command(&cli.Command{ Name: "user", Aliases: []string{"us"}, diff --git a/pkg/cache/user.go b/pkg/cache/user.go index fcd31ec..c1f34a8 100755 --- a/pkg/cache/user.go +++ b/pkg/cache/user.go @@ -4,12 +4,13 @@ import ( "bufio" "crypto/x509" "encoding/pem" - "github.com/luscis/openlan/pkg/libol" - "github.com/luscis/openlan/pkg/models" "io/ioutil" "strings" "sync" "time" + + "github.com/luscis/openlan/pkg/libol" + "github.com/luscis/openlan/pkg/models" ) type user struct { @@ -45,7 +46,7 @@ func (w *user) Load() { if len(columns) > 3 { leStr = columns[3] } - lease, _ := libol.GetLocalTime(libol.LeaseTime, leStr) + lease, _ := libol.GetLeaseTime(leStr) obj := &models.User{ Name: user, Password: pass, diff --git a/pkg/libol/utils.go b/pkg/libol/utils.go index 278c834..b13274a 100755 --- a/pkg/libol/utils.go +++ b/pkg/libol/utils.go @@ -306,6 +306,10 @@ func GetLocalTime(layout, value string) (time.Time, error) { return time.ParseInLocation(layout, value, time.Local) } +func GetLeaseTime(value string) (time.Time, error) { + return time.ParseInLocation(LeaseTime, value, time.Local) +} + func Base64Decode(value string) ([]byte, error) { return base64.StdEncoding.DecodeString(value) } diff --git a/pkg/models/schema.go b/pkg/models/schema.go index c37b1f3..d3f2ac9 100755 --- a/pkg/models/schema.go +++ b/pkg/models/schema.go @@ -80,7 +80,7 @@ func NewUserSchema(u *User) schema.User { } func SchemaToUserModel(user *schema.User) *User { - lease, _ := libol.GetLocalTime(libol.LeaseTime, user.Lease) + lease, _ := libol.GetLeaseTime(user.Lease) obj := &User{ Alias: user.Alias, Password: user.Password,