mirror of
https://shylinux.com/x/community
synced 2025-07-01 13:14:44 +08:00
add some
This commit is contained in:
parent
f9138c8588
commit
fd4f3a4195
54
src/gonganxitong/grant.go
Normal file
54
src/gonganxitong/grant.go
Normal file
@ -0,0 +1,54 @@
|
||||
package gonganxitong
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
type grant struct {
|
||||
Tables
|
||||
sess sess
|
||||
confirm string `name:"confirm" role:"void"`
|
||||
list string `name:"list name auto" help:"扫码授权" role:"void"`
|
||||
}
|
||||
|
||||
func (s grant) List(m *ice.Message, arg ...string) {
|
||||
if m.Option(ice.FROM_DAEMON) == "" {
|
||||
m.EchoQRCode(m.MergePodCmd("", m.PrefixKey(), ice.FROM_DAEMON, m.Option(ice.MSG_DAEMON)))
|
||||
} else {
|
||||
m.EchoInfoButton("请授权登录", s.Confirm)
|
||||
}
|
||||
kit.If(m.IsTech(), func() { m.Action(s.Header) })
|
||||
}
|
||||
func (s grant) Header(m *ice.Message, arg ...string) {
|
||||
m.AddHeaderLogin(mdb.PLUGIN, "weixin", "微信扫码", "9")
|
||||
m.Cmd(web.SPACE, ice.OPS, web.SERVE, ice.MAIN, m.Prefix("portal"), m.Option(ice.MSG_USERPOD))
|
||||
}
|
||||
func (s grant) Confirm(m *ice.Message, arg ...string) {
|
||||
if m.WarnNotAllow(m.Option(ice.MSG_METHOD) == http.MethodGet) {
|
||||
return
|
||||
} else if m.WarnNotLogin(m.Option(ice.MSG_USERNAME) == "") || m.WarnNotValid(m.Option(ice.FROM_DAEMON) == "", ice.FROM_DAEMON) {
|
||||
return
|
||||
} else if msg := s.spaceInfo(m); m.WarnNotFound(msg.Append(mdb.TYPE) == "", m.Option(web.SPACE)) {
|
||||
return
|
||||
} else {
|
||||
m.Info("what %v", msg.FormatsMeta(nil))
|
||||
defer m.ProcessOpen(msg.Append(mdb.TEXT))
|
||||
m.Option(ice.MSG_USERIP, msg.Append(aaa.IP))
|
||||
m.Option(ice.MSG_USERUA, msg.Append(aaa.UA))
|
||||
msg := m.Cmd(s.sess, s.Create)
|
||||
m.Cmd(web.SPACE, m.Option(ice.FROM_DAEMON), ice.MSG_SESSID, msg.Option(ice.MSG_SESSID))
|
||||
m.Echo(ice.SUCCESS)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(grant{Tables: newTables()}) }
|
||||
|
||||
func (s grant) spaceInfo(m *ice.Message, arg ...string) *ice.Message {
|
||||
return m.Cmd(web.SPACE, kit.Keys(kit.Slice(kit.Split(m.Option(ice.FROM_DAEMON), "."), 0, -1)))
|
||||
}
|
@ -17,7 +17,7 @@ type sess struct {
|
||||
|
||||
func (s sess) Create(m *ice.Message, arg ...string) {
|
||||
s.Insert(m, model.USER_UID, m.Option(model.USER_UID), web.AGENT, m.Option(ice.MSG_USERUA), aaa.IP, m.Option(ice.MSG_USERIP))
|
||||
m.ProcessCookie(ice.MSG_SESSID, kit.JoinWord(web.SPACE, m.Option(ice.MSG_USERPOD), m.PrefixKey(), aaa.CHECK, m.Result()), "-2")
|
||||
m.ProcessCookie(ice.MSG_SESSID, m.Option(ice.MSG_SESSID, kit.JoinWord(web.SPACE, m.Option(ice.MSG_USERPOD), m.PrefixKey(), aaa.CHECK, m.Result())), "-2")
|
||||
}
|
||||
func (s sess) Check(m *ice.Message, arg ...string) {
|
||||
msg := s.Select(m.Spawn(), model.UID, arg[0])
|
||||
|
Loading…
x
Reference in New Issue
Block a user