forked from x/icebergs
opt some
This commit is contained in:
parent
bbff450bf9
commit
ee043fd1c5
@ -36,21 +36,21 @@ func _user_modify(m *ice.Message, name string, arg ...string) {
|
|||||||
_user_create(m, name, "")
|
_user_create(m, name, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Richs(USER, nil, name, func(key string, value map[string]interface{}) {
|
|
||||||
m.Log_MODIFY(USERNAME, name, arg)
|
m.Log_MODIFY(USERNAME, name, arg)
|
||||||
|
m.Richs(USER, nil, name, func(key string, value map[string]interface{}) {
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
for i := 0; i < len(arg)-1; i += 2 {
|
||||||
kit.Value(value, arg[i], arg[i+1])
|
kit.Value(value, arg[i], arg[i+1])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _user_create(m *ice.Message, name, word string) {
|
func _user_create(m *ice.Message, name, word string) {
|
||||||
m.Rich(USER, nil, kit.Dict(
|
h := m.Rich(USER, nil, kit.Dict(
|
||||||
USERNAME, name, PASSWORD, word,
|
USERNAME, name, PASSWORD, word,
|
||||||
USERNICK, name, USERNODE, cli.NodeName,
|
USERNICK, name, USERNODE, cli.NodeName,
|
||||||
USERZONE, m.Option(ice.MSG_USERZONE),
|
USERZONE, m.Option(ice.MSG_USERZONE),
|
||||||
USERNODE, cli.NodeName,
|
USERNODE, cli.NodeName,
|
||||||
))
|
))
|
||||||
m.Log_CREATE(USERNAME, name)
|
m.Log_CREATE(USERNAME, name, "hash", h)
|
||||||
m.Event(gdb.USER_CREATE, name)
|
m.Event(gdb.USER_CREATE, name)
|
||||||
}
|
}
|
||||||
func _user_search(m *ice.Message, kind, name, text string, arg ...string) {
|
func _user_search(m *ice.Message, kind, name, text string, arg ...string) {
|
||||||
@ -119,8 +119,8 @@ func init() {
|
|||||||
mdb.CREATE: {Name: "create username [password]", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create username [password]", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_user_create(m, arg[0], kit.Select("", arg, 1))
|
_user_create(m, arg[0], kit.Select("", arg, 1))
|
||||||
}},
|
}},
|
||||||
mdb.MODIFY: {Name: "modify username [key value]...", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
mdb.MODIFY: {Name: "modify [key value]...", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_user_modify(m, m.Option("username"), arg[0], arg[1])
|
_user_modify(m, m.Option(USERNAME), arg...)
|
||||||
}},
|
}},
|
||||||
mdb.SEARCH: {Name: "search type name text arg...", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Name: "search type name text arg...", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_user_search(m, arg[0], arg[1], kit.Select("", arg, 2))
|
_user_search(m, arg[0], arg[1], kit.Select("", arg, 2))
|
||||||
|
@ -24,6 +24,11 @@ func _file_ext(name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _file_list(m *ice.Message, root string, name string, level int, deep bool, dir_type string, dir_reg *regexp.Regexp, fields []string) {
|
func _file_list(m *ice.Message, root string, name string, level int, deep bool, dir_type string, dir_reg *regexp.Regexp, fields []string) {
|
||||||
|
switch strings.Split(name, "/")[0] {
|
||||||
|
case "etc", "var":
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if fs, e := ioutil.ReadDir(path.Join(root, name)); e != nil {
|
if fs, e := ioutil.ReadDir(path.Join(root, name)); e != nil {
|
||||||
if f, e := os.Open(path.Join(root, name)); e == nil {
|
if f, e := os.Open(path.Join(root, name)); e == nil {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
const LOGIN = "_login"
|
const LOGIN = "_login"
|
||||||
|
|
||||||
func _serve_login(msg *ice.Message, cmds []string, w http.ResponseWriter, r *http.Request) ([]string, bool) {
|
func _serve_login(msg *ice.Message, cmds []string, w http.ResponseWriter, r *http.Request) ([]string, bool) {
|
||||||
|
msg.Debug("what", msg.Conf("aaa.user"))
|
||||||
msg.Option(ice.MSG_USERNAME, "")
|
msg.Option(ice.MSG_USERNAME, "")
|
||||||
msg.Option(ice.MSG_USERROLE, "")
|
msg.Option(ice.MSG_USERROLE, "")
|
||||||
|
|
||||||
@ -191,7 +192,15 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
|||||||
if r.ParseForm(); r.FormValue(ice.MSG_SESSID) != "" {
|
if r.ParseForm(); r.FormValue(ice.MSG_SESSID) != "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if c, e := r.Cookie(ice.MSG_SESSID); e != nil || c.Value == "" {
|
|
||||||
|
sessid := ""
|
||||||
|
if c, e := r.Cookie(ice.MSG_SESSID); e == nil {
|
||||||
|
m.Richs("aaa.sess", "", c.Value, func(key string, value map[string]interface{}) {
|
||||||
|
sessid = c.Value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if sessid == "" {
|
||||||
http.Redirect(w, r, m.Conf(SERVE, "meta.sso"), http.StatusTemporaryRedirect)
|
http.Redirect(w, r, m.Conf(SERVE, "meta.sso"), http.StatusTemporaryRedirect)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -95,11 +95,16 @@ func init() {
|
|||||||
RIVER: {Name: "river", Help: "群组", Value: kit.Data(
|
RIVER: {Name: "river", Help: "群组", Value: kit.Data(
|
||||||
"template", kit.Dict(
|
"template", kit.Dict(
|
||||||
"base", kit.Dict(
|
"base", kit.Dict(
|
||||||
"admin", []interface{}{
|
"info", []interface{}{
|
||||||
"web.chat.user",
|
"web.chat.user",
|
||||||
"web.chat.tool",
|
"web.chat.tool",
|
||||||
"web.chat.info",
|
"web.chat.info",
|
||||||
},
|
},
|
||||||
|
"miss", []interface{}{
|
||||||
|
"web.team.task",
|
||||||
|
"web.team.plan",
|
||||||
|
"web.wiki.word",
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
aaa.Black, kit.Dict(aaa.TECH, []interface{}{
|
aaa.Black, kit.Dict(aaa.TECH, []interface{}{
|
||||||
@ -238,9 +243,6 @@ func init() {
|
|||||||
_river_node(m, m.Option(ice.MSG_RIVER), arg...)
|
_river_node(m, m.Option(ice.MSG_RIVER), arg...)
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if m.Option(ice.MSG_USERNICK) != "" {
|
|
||||||
m.Cmd(aaa.USER, mdb.MODIFY, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK))
|
|
||||||
}
|
|
||||||
if len(arg) > 0 && arg[0] == "storm" {
|
if len(arg) > 0 && arg[0] == "storm" {
|
||||||
m.Cmdy("/storm", arg[1:])
|
m.Cmdy("/storm", arg[1:])
|
||||||
return
|
return
|
||||||
|
@ -524,14 +524,18 @@ var Index = &ice.Context{Name: "lark", Help: "机器人",
|
|||||||
"app_access_token", m.Cmdx(APP, "token", "bot"),
|
"app_access_token", m.Cmdx(APP, "token", "bot"),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
m.Option(aaa.USERZONE, LARK)
|
||||||
m.Option(ice.MSG_USERROLE, aaa.ROOT)
|
m.Option(ice.MSG_USERROLE, aaa.ROOT)
|
||||||
user := kit.Format(kit.Value(data, "data.open_id"))
|
user := kit.Format(kit.Value(data, "data.open_id"))
|
||||||
web.RenderCookie(m, aaa.SessCreate(m, user, aaa.UserRole(m, user)))
|
web.RenderCookie(m, aaa.SessCreate(m, user, aaa.UserRole(m, user)))
|
||||||
m.Render("redirect", m.Conf(web.SHARE, "meta.domain"))
|
m.Render("redirect", m.Conf(web.SHARE, "meta.domain"))
|
||||||
|
|
||||||
m.Debug("data %v", kit.Format(data))
|
m.Option(aaa.USERNAME, user)
|
||||||
m.Cmd(aaa.USER, mdb.MODIFY, user,
|
msg := m.Cmd(m.Prefix(USER), user)
|
||||||
aaa.USERNICK, kit.Value(data, "data.name"),
|
m.Cmd(aaa.USER, mdb.MODIFY, aaa.USERZONE, LARK, aaa.USERNICK, msg.Append("name"),
|
||||||
|
"mobile", msg.Append("mobile"), "avatar_url", msg.Append("avatar_url"),
|
||||||
|
"gender", kit.Select("女", "男", msg.Append("gender") == "1"),
|
||||||
|
"country", msg.Append("country"), "city", msg.Append("city"),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
@ -47,14 +47,13 @@ var Index = &ice.Context{Name: "mp", Help: "小程序",
|
|||||||
|
|
||||||
case "info":
|
case "info":
|
||||||
// 用户信息
|
// 用户信息
|
||||||
m.Cmd(aaa.USER, mdb.MODIFY, m.Option(ice.MSG_USERNAME),
|
m.Option(aaa.USERNAME, m.Option(ice.MSG_USERNAME))
|
||||||
"gender", m.Option("gender"),
|
m.Cmd(aaa.USER, mdb.MODIFY, aaa.USERZONE, MP, aaa.USERNICK, m.Option("nickName"),
|
||||||
"avatar", m.Option("avatarUrl"),
|
"avatar_url", m.Option("avatarUrl"),
|
||||||
"usernick", m.Option("nickName"),
|
"gender", kit.Select("女", "男", m.Option("gender") == "1"),
|
||||||
|
"country", m.Option("country"), "city", m.Option("city"),
|
||||||
"language", m.Option("language"),
|
"language", m.Option("language"),
|
||||||
"province", m.Option("province"),
|
"province", m.Option("province"),
|
||||||
"country", m.Option("country"),
|
|
||||||
"city", m.Option("city"),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
case "scan":
|
case "scan":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user