mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt sso
This commit is contained in:
parent
efd2eb3c08
commit
cee53d8626
@ -32,11 +32,11 @@ func Render(msg *ice.Message, cmd string, args ...interface{}) {
|
||||
RenderCookie(msg, arg[0], arg[1:]...)
|
||||
|
||||
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]]
|
||||
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
|
||||
}
|
||||
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
|
||||
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,
|
||||
Name: kit.Select(ice.MSG_SESSID, arg, 0), Path: kit.Select("/", arg, 1), Expires: expire})
|
||||
}
|
||||
|
@ -86,10 +86,8 @@ 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 "/sso":
|
||||
return
|
||||
case "/pod/":
|
||||
return // 免登录
|
||||
case "/header":
|
||||
@ -154,9 +152,7 @@ func init() {
|
||||
if m.Cmd(GRANT, m.Option(ice.POD), 1).Length() > 0 {
|
||||
_header_grant(m, web.SPACE, m.Option(GRANT))
|
||||
}
|
||||
m.Debug("what %v", m.FormatMeta())
|
||||
m.Option(GRANT, ice.TRUE)
|
||||
m.Debug("what %v", m.FormatMeta())
|
||||
}
|
||||
|
||||
m.Option(TRANS, kit.Format(kit.Value(c.Commands[cmd].Meta, "_trans")))
|
||||
|
@ -13,6 +13,10 @@ 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) {
|
||||
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,
|
||||
mdb.TIME, m.Time("720h"),
|
||||
aaa.USERROLE, m.Option(ice.MSG_USERROLE),
|
||||
@ -20,6 +24,8 @@ func init() {
|
||||
aaa.USERNICK, m.Option(ice.MSG_USERNICK),
|
||||
)
|
||||
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")))
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user