mirror of
https://gitee.com/gokins/gokins.git
synced 2024-11-29 17:57:50 +08:00
commit
48bf19dad0
26
main.go
26
main.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"gokins/comm"
|
||||
"gokins/core"
|
||||
"gokins/mgr"
|
||||
@ -13,6 +14,8 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var clearPass = ""
|
||||
|
||||
func init() {
|
||||
path, err := os.Executable()
|
||||
if err != nil {
|
||||
@ -29,6 +32,7 @@ func init() {
|
||||
println("dir:" + dir)
|
||||
flag.StringVar(&comm.Dir, "d", dir, "数据目录")
|
||||
flag.StringVar(&comm.Host, "bind", ":8030", "绑定地址")
|
||||
flag.StringVar(&clearPass, "clp", "", "清除用户密码(请先关闭服务在执行)")
|
||||
flag.Parse()
|
||||
comm.Gin = gin.Default()
|
||||
}
|
||||
@ -38,6 +42,9 @@ func main() {
|
||||
println("InitDb err:" + err.Error())
|
||||
return
|
||||
}
|
||||
if clearUPass() {
|
||||
return
|
||||
}
|
||||
jwtKey := dbService.GetParam("jwt-key")
|
||||
jkey := jwtKey.GetString("key")
|
||||
if jkey == "" {
|
||||
@ -54,3 +61,22 @@ func main() {
|
||||
}
|
||||
mgr.Cancel()
|
||||
}
|
||||
|
||||
func clearUPass() bool {
|
||||
if clearPass != "" {
|
||||
usr := dbService.FindUserName(clearPass)
|
||||
if usr == nil {
|
||||
fmt.Printf("user(%s) not found\n", clearPass)
|
||||
} else {
|
||||
usr.Pass = ""
|
||||
_, err := comm.Db.Cols("pass").Where("id=?", usr.Id).Update(usr)
|
||||
if err != nil {
|
||||
fmt.Println("clear password err:" + err.Error())
|
||||
} else {
|
||||
fmt.Println("clear password ok")
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user