diff --git a/base/cli/system.go b/base/cli/system.go index 254f3bb9..40b4f613 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -3,6 +3,7 @@ package cli import ( "bytes" "io" + "io/ioutil" "os" "os/exec" "path" @@ -31,9 +32,6 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd { for i := 0; i < len(env)-1; i += 2 { cmd.Env = append(cmd.Env, kit.Format("%s=%s", env[i], env[i+1])) if env[i] == PATH { - // if strings.Contains(m.Cmdx(RUNTIME, "host.OSID"), ALPINE) { - // continue - // } if file := _system_find(m, arg[0], strings.Split(env[i+1], ice.DF)...); file != "" { cmd.Path = file break @@ -42,15 +40,12 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd { } // // 定制目录 - // if buf, err := ioutil.ReadFile(ice.ETC_PATH); err == nil && len(buf) > 0 { - // for _, p := range strings.Split(string(buf), ice.NL) { - // if _, e := os.Stat(path.Join(p, arg[0])); e == nil { - // cmd.Path = kit.Path(path.Join(p, arg[0])) - // m.Debug("what %v", cmd.Path) - // break - // } - // } - // } + if buf, err := ioutil.ReadFile(ice.ETC_PATH); err == nil && len(buf) > 0 { + if file := _system_find(m, arg[0], strings.Split(string(buf), ice.NL)...); file != "" { + // cmd.Path = file + // break + } + } m.Debug("cmd: %v", cmd.Path) if len(cmd.Env) > 0 { diff --git a/base/web/render.go b/base/web/render.go index b2edef8c..ab5ae4f9 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -32,7 +32,7 @@ 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:]), http.StatusSeeOther) + RenderRedirect(msg, arg...) case ice.RENDER_DOWNLOAD: // file [type [name]] if strings.HasPrefix(arg[0], "http") { @@ -88,6 +88,9 @@ func RenderCookie(msg *ice.Message, value string, arg ...string) { // name path http.SetCookie(msg.W, &http.Cookie{Value: value, Name: kit.Select(CookieName(msg.Option(ice.MSG_USERWEB)), arg, 0), Path: kit.Select(ice.PS, arg, 1), Expires: expire}) } +func RenderRedirect(msg *ice.Message, arg ...string) { + http.Redirect(msg.W, msg.R, kit.MergeURL(arg[0], arg[1:]), http.StatusMovedPermanently) +} func RenderType(w http.ResponseWriter, name, mime string) { if mime != "" { w.Header().Set(ContentType, mime) diff --git a/base/web/serve.go b/base/web/serve.go index 2f2c02a4..bb89e99e 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -184,12 +184,10 @@ func _serve_login(msg *ice.Message, key string, cmds []string, w http.ResponseWr if msg.Option(ice.MSG_USERNAME) == "" && msg.Option(SHARE) != "" { switch share := msg.Cmd(SHARE, msg.Option(SHARE)); share.Append(mdb.TYPE) { - case LOGIN: // 共享认证 - msg.Option(ice.MSG_USERROLE, share.Append(aaa.USERROLE)) - msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME)) - case FIELD: // 共享认证 + case STORM, FIELD: // 共享认证 msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME)) msg.Option(ice.MSG_USERROLE, share.Append(aaa.USERROLE)) + msg.Option(ice.MSG_USERNICK, share.Append(aaa.USERNICK)) } } diff --git a/base/web/share.go b/base/web/share.go index 29c388c4..0ca90479 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -162,8 +162,19 @@ func init() { if msg := m.Cmd(SHARE, m.Option(SHARE)); kit.Int(msg.Append(mdb.TIME)) < kit.Int(msg.FormatTime()) { m.RenderResult("共享超时") return + } else { + switch msg.Append(mdb.TYPE) { + case LOGIN: + if sessid := aaa.SessCreate(m, msg.Append(aaa.USERNAME)); m.Option(ice.MSG_USERWEB) == "" { + m.RenderRedirect(ice.PS, ice.MSG_SESSID, sessid) + } else { + RenderCookie(m, sessid) + RenderRedirect(m, ice.PS) + } + default: + m.RenderIndex(SERVE, ice.VOLCANOS) + } } - m.RenderIndex(SERVE, ice.VOLCANOS) }}, SHARE_TOAST: {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { diff --git a/core/chat/header.go b/core/chat/header.go index 832a695b..14d251dc 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -21,20 +21,6 @@ func _header_agent(m *ice.Message, arg ...string) { } } func _header_check(m *ice.Message, arg ...string) { - if m.Option(web.SHARE) != "" { - switch msg := m.Cmd(web.SHARE, m.Option(web.SHARE)); msg.Append(mdb.TYPE) { - case web.LOGIN: - if m.Option(ice.MSG_USERNAME) != msg.Append(aaa.USERNAME) { - web.RenderCookie(m, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)))) - m.Option(ice.MSG_USERNICK, aaa.UserNick(m, msg.Append(aaa.USERNAME))) - } - case web.STORM: - m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)) - case web.FIELD: - m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)) - } - } - if m.Option(ice.MSG_USERNAME) == "" { m.Option(web.LOGIN, m.Config(web.LOGIN)) m.Option(web.SSO, m.Conf(web.SERVE, kit.Keym(web.SSO))) @@ -143,9 +129,8 @@ func init() { m.Cmdy(code.WEBPACK, mdb.REMOVE) }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Option(aaa.USERNICK, m.Option(ice.MSG_USERNICK)) msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)) - for _, k := range []string{aaa.LANGUAGE, aaa.BACKGROUND, aaa.AVATAR} { + for _, k := range []string{aaa.LANGUAGE, aaa.BACKGROUND, aaa.AVATAR, aaa.USERNICK} { m.Option(k, msg.Append(k)) }