default user login + issuer
This commit is contained in:
parent
47ccd31e69
commit
b5bcbd2e07
4 changed files with 26 additions and 1 deletions
|
|
@ -71,6 +71,12 @@ var rootCmd = &cobra.Command{
|
||||||
DisableDefaultCmd: true,
|
DisableDefaultCmd: true,
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
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)
|
fmt.Fprintln(os.Stderr, L("One or more arguments are not correct"), args)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
},
|
},
|
||||||
|
|
@ -86,7 +92,7 @@ func init() {
|
||||||
runCmd,
|
runCmd,
|
||||||
initCmd,
|
initCmd,
|
||||||
)
|
)
|
||||||
rootCmd.SetHelpCommand(helpCmd)
|
// rootCmd.SetHelpCommand(helpCmd)
|
||||||
rootCmd.PersistentFlags().StringVarP(&appPath, "app", "a", "", L("Application directory"))
|
rootCmd.PersistentFlags().StringVarP(&appPath, "app", "a", "", L("Application directory"))
|
||||||
rootCmd.PersistentFlags().StringVarP(&envFile, "env", "e", "", L("Environment file"))
|
rootCmd.PersistentFlags().StringVarP(&envFile, "env", "e", "", L("Environment file"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
cmd/tea.go
Normal file
16
cmd/tea.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func fuxi() {
|
||||||
|
fmt.Println(`
|
||||||
|
━━━━━━ ━━ ━━ ━━━━━━ ━━ ━━ ━━━━━━ ━━━━━━ ━━ ━━ ━━ ━━
|
||||||
|
━━━━━━ ━━━━━━ ━━ ━━ ━━ ━━ ━━━━━━ ━━ ━━ ━━ ━━ ━━━━━━
|
||||||
|
━━━━━━ ━━ ━━ ━━ ━━ ━━━━━━ ━━ ━━ ━━━━━━ ━━ ━━ ━━━━━━
|
||||||
|
乾 坎 艮 震 巽 离 坤 兑
|
||||||
|
`)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,7 @@ func TestJwt(t *testing.T) {
|
||||||
assert.NotNil(t, res)
|
assert.NotNil(t, res)
|
||||||
assert.Equal(t, float64(1), res.Data["id"])
|
assert.Equal(t, float64(1), res.Data["id"])
|
||||||
assert.Equal(t, "world", res.Data["hello"])
|
assert.Equal(t, "world", res.Data["hello"])
|
||||||
|
assert.Equal(t, "UnitTest", res.Issuer)
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
assert.Panics(t, func() { JwtValidate(tokenString) })
|
assert.Panics(t, func() { JwtValidate(tokenString) })
|
||||||
}
|
}
|
||||||
|
|
@ -31,6 +32,7 @@ func TestProcessJwt(t *testing.T) {
|
||||||
res := gou.NewProcess("xiang.helper.JwtValidate", tokenString).Run().(*JwtClaims)
|
res := gou.NewProcess("xiang.helper.JwtValidate", tokenString).Run().(*JwtClaims)
|
||||||
assert.Equal(t, float64(1), res.Data["id"])
|
assert.Equal(t, float64(1), res.Data["id"])
|
||||||
assert.Equal(t, "world", res.Data["hello"])
|
assert.Equal(t, "world", res.Data["hello"])
|
||||||
|
assert.Equal(t, "UnitTest", res.Issuer)
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
assert.Panics(t, func() { gou.NewProcess("xiang.helper.JwtValidate", tokenString).Run() })
|
assert.Panics(t, func() { gou.NewProcess("xiang.helper.JwtValidate", tokenString).Run() })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ func Auth(field string, value string, password string) maps.Map {
|
||||||
token := helper.JwtMake(id, map[string]interface{}{}, map[string]interface{}{
|
token := helper.JwtMake(id, map[string]interface{}{}, map[string]interface{}{
|
||||||
"expires_at": expiresAt,
|
"expires_at": expiresAt,
|
||||||
"sid": sid,
|
"sid": sid,
|
||||||
|
"issuer": "xiang",
|
||||||
})
|
})
|
||||||
session.Global().Expire(time.Duration(token.ExpiresAt)*time.Second).ID(sid).Set("user_id", id)
|
session.Global().Expire(time.Duration(token.ExpiresAt)*time.Second).ID(sid).Set("user_id", id)
|
||||||
session.Global().ID(sid).Set("user", row)
|
session.Global().ID(sid).Set("user", row)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue