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 14:04:52 +08:00
parent efd2eb3c08
commit cee53d8626
3 changed files with 11 additions and 8 deletions

View File

@ -32,11 +32,11 @@ func Render(msg *ice.Message, cmd string, args ...interface{}) {
RenderCookie(msg, arg[0], arg[1:]...) RenderCookie(msg, arg[0], arg[1:]...)
case ice.RENDER_REDIRECT: // url [arg...] case ice.RENDER_REDIRECT: // url [arg...]
http.Redirect(msg.W, msg.R, kit.MergeURL(arg[0], arg[1:]), 307) http.Redirect(msg.W, msg.R, kit.MergeURL(arg[0], arg[1:]), http.StatusSeeOther)
case ice.RENDER_DOWNLOAD: // file [type [name]] case ice.RENDER_DOWNLOAD: // file [type [name]]
if strings.HasPrefix(arg[0], "http") { if strings.HasPrefix(arg[0], "http") {
http.Redirect(msg.W, msg.R, arg[0], 307) http.Redirect(msg.W, msg.R, arg[0], http.StatusSeeOther)
break break
} }
msg.W.Header().Set("Content-Disposition", fmt.Sprintf("filename=%s", kit.Select(path.Base(kit.Select(arg[0], msg.Option("filename"))), arg, 2))) msg.W.Header().Set("Content-Disposition", fmt.Sprintf("filename=%s", kit.Select(path.Base(kit.Select(arg[0], msg.Option("filename"))), arg, 2)))
@ -85,6 +85,7 @@ func CookieName(url string) string {
} }
func RenderCookie(msg *ice.Message, value string, arg ...string) { // name path expire func RenderCookie(msg *ice.Message, value string, arg ...string) { // name path expire
expire := time.Now().Add(kit.Duration(kit.Select(msg.Conf(aaa.SESS, "meta.expire"), arg, 2))) expire := time.Now().Add(kit.Duration(kit.Select(msg.Conf(aaa.SESS, "meta.expire"), arg, 2)))
msg.Debug("what %v %v", value, arg)
http.SetCookie(msg.W, &http.Cookie{Value: value, http.SetCookie(msg.W, &http.Cookie{Value: value,
Name: kit.Select(ice.MSG_SESSID, arg, 0), Path: kit.Select("/", arg, 1), Expires: expire}) Name: kit.Select(ice.MSG_SESSID, arg, 0), Path: kit.Select("/", arg, 1), Expires: expire})
} }

View File

@ -86,10 +86,8 @@ func init() {
}, Commands: map[string]*ice.Command{ }, Commands: map[string]*ice.Command{
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
switch arg[0] { switch arg[0] {
case "/sso/": case "/sso":
if m.Option(ice.MSG_USERNAME) != "" { return
return
}
case "/pod/": case "/pod/":
return // 免登录 return // 免登录
case "/header": case "/header":
@ -154,9 +152,7 @@ func init() {
if m.Cmd(GRANT, m.Option(ice.POD), 1).Length() > 0 { if m.Cmd(GRANT, m.Option(ice.POD), 1).Length() > 0 {
_header_grant(m, web.SPACE, m.Option(GRANT)) _header_grant(m, web.SPACE, m.Option(GRANT))
} }
m.Debug("what %v", m.FormatMeta())
m.Option(GRANT, ice.TRUE) m.Option(GRANT, ice.TRUE)
m.Debug("what %v", m.FormatMeta())
} }
m.Option(TRANS, kit.Format(kit.Value(c.Commands[cmd].Meta, "_trans"))) m.Option(TRANS, kit.Format(kit.Value(c.Commands[cmd].Meta, "_trans")))

View File

@ -13,6 +13,10 @@ const SSO = "sso"
func init() { func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ 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) { "/sso": {Name: "/sso", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if m.Option(ice.MSG_USERNAME) == "" {
m.RenderIndex(web.SERVE, ice.VOLCANOS)
return
}
sessid := m.Cmdx(web.SPACE, m.Option(web.SPACE), aaa.SESS, mdb.CREATE, sessid := m.Cmdx(web.SPACE, m.Option(web.SPACE), aaa.SESS, mdb.CREATE,
mdb.TIME, m.Time("720h"), mdb.TIME, m.Time("720h"),
aaa.USERROLE, m.Option(ice.MSG_USERROLE), aaa.USERROLE, m.Option(ice.MSG_USERROLE),
@ -20,6 +24,8 @@ func init() {
aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNICK, m.Option(ice.MSG_USERNICK),
) )
m.RenderRedirect(kit.MergeURL(m.Option("back"), ice.MSG_SESSID, sessid)) m.RenderRedirect(kit.MergeURL(m.Option("back"), ice.MSG_SESSID, sessid))
// web.RenderCookie(m, sessid, web.CookieName(m.Option("back")))
// m.RenderRedirect(kit.MergeURL(m.Option("back")))
}}, }},
}}) }})
} }