diff --git a/cmd/root.go b/cmd/root.go index 6850188c..fc40b6f0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -71,6 +71,12 @@ var rootCmd = &cobra.Command{ DisableDefaultCmd: true, }, Run: func(cmd *cobra.Command, args []string) { + if len(args) > 0 { + switch args[0] { + case "fuxi": + fuxi() + } + } fmt.Fprintln(os.Stderr, L("One or more arguments are not correct"), args) os.Exit(1) }, @@ -86,7 +92,7 @@ func init() { runCmd, initCmd, ) - rootCmd.SetHelpCommand(helpCmd) + // rootCmd.SetHelpCommand(helpCmd) rootCmd.PersistentFlags().StringVarP(&appPath, "app", "a", "", L("Application directory")) rootCmd.PersistentFlags().StringVarP(&envFile, "env", "e", "", L("Environment file")) } diff --git a/cmd/tea.go b/cmd/tea.go new file mode 100644 index 00000000..3868466f --- /dev/null +++ b/cmd/tea.go @@ -0,0 +1,16 @@ +package cmd + +import ( + "fmt" + "os" +) + +func fuxi() { + fmt.Println(` + ━━━━━━ ━━ ━━ ━━━━━━ ━━ ━━ ━━━━━━ ━━━━━━ ━━ ━━ ━━ ━━ + ━━━━━━ ━━━━━━ ━━ ━━ ━━ ━━ ━━━━━━ ━━ ━━ ━━ ━━ ━━━━━━ + ━━━━━━ ━━ ━━ ━━ ━━ ━━━━━━ ━━ ━━ ━━━━━━ ━━ ━━ ━━━━━━ + 乾 坎 艮 震 巽 离 坤 兑 + `) + os.Exit(0) +} diff --git a/helper/jwt_test.go b/helper/jwt_test.go index 59707b27..60d977a0 100644 --- a/helper/jwt_test.go +++ b/helper/jwt_test.go @@ -17,6 +17,7 @@ func TestJwt(t *testing.T) { assert.NotNil(t, res) assert.Equal(t, float64(1), res.Data["id"]) assert.Equal(t, "world", res.Data["hello"]) + assert.Equal(t, "UnitTest", res.Issuer) time.Sleep(2 * time.Second) assert.Panics(t, func() { JwtValidate(tokenString) }) } @@ -31,6 +32,7 @@ func TestProcessJwt(t *testing.T) { res := gou.NewProcess("xiang.helper.JwtValidate", tokenString).Run().(*JwtClaims) assert.Equal(t, float64(1), res.Data["id"]) assert.Equal(t, "world", res.Data["hello"]) + assert.Equal(t, "UnitTest", res.Issuer) time.Sleep(2 * time.Second) assert.Panics(t, func() { gou.NewProcess("xiang.helper.JwtValidate", tokenString).Run() }) } diff --git a/user/user.go b/user/user.go index 15ef8fee..d3a0439d 100644 --- a/user/user.go +++ b/user/user.go @@ -68,6 +68,7 @@ func Auth(field string, value string, password string) maps.Map { token := helper.JwtMake(id, map[string]interface{}{}, map[string]interface{}{ "expires_at": expiresAt, "sid": sid, + "issuer": "xiang", }) session.Global().Expire(time.Duration(token.ExpiresAt)*time.Second).ID(sid).Set("user_id", id) session.Global().ID(sid).Set("user", row)