1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2022-01-03 13:31:44 +08:00
parent c7d8d33e2c
commit efd2eb3c08
3 changed files with 31 additions and 1 deletions

View File

@ -135,7 +135,7 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
}
// 请求地址
msg.Option(ice.MSG_USERWEB, kit.Select(msg.Config(DOMAIN), kit.Select(r.Header.Get("X-Host"), r.Header.Get("Referer"))))
msg.Option(ice.MSG_USERWEB, kit.Select(msg.Config(DOMAIN), kit.Select(r.Header.Get("Referer"), r.Header.Get("X-Host"))))
msg.Option(ice.MSG_USERADDR, kit.Select(r.RemoteAddr, r.Header.Get(ice.MSG_USERADDR)))
msg.Option(ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP))
msg.Option(ice.MSG_USERUA, r.Header.Get("User-Agent"))
@ -145,6 +145,7 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
if sessid := msg.Option(CookieName(msg.Option(ice.MSG_USERWEB))); sessid != "" {
msg.Option(ice.MSG_SESSID, sessid)
}
msg.Debug("what %v", msg.FormatMeta())
// 参数转换
for k, v := range r.Form {

View File

@ -86,6 +86,10 @@ func init() {
}, Commands: map[string]*ice.Command{
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
switch arg[0] {
case "/sso/":
if m.Option(ice.MSG_USERNAME) != "" {
return
}
case "/pod/":
return // 免登录
case "/header":

25
core/chat/sso.go Normal file
View File

@ -0,0 +1,25 @@
package chat
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
const SSO = "sso"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
"/sso": {Name: "/sso", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
sessid := m.Cmdx(web.SPACE, m.Option(web.SPACE), aaa.SESS, mdb.CREATE,
mdb.TIME, m.Time("720h"),
aaa.USERROLE, m.Option(ice.MSG_USERROLE),
aaa.USERNAME, m.Option(ice.MSG_USERNAME),
aaa.USERNICK, m.Option(ice.MSG_USERNICK),
)
m.RenderRedirect(kit.MergeURL(m.Option("back"), ice.MSG_SESSID, sessid))
}},
}})
}