diff --git a/base/web/serve.go b/base/web/serve.go index ad043fbd..2ec92c07 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -190,6 +190,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response kit.For(r.Cookies(), func(k, v string) { m.Optionv(k, v) }) m.Options(ice.MSG_METHOD, r.Method, ice.MSG_COUNT, "0") m.Options(ice.MSG_REFERER, r.Header.Get(html.Referer)) + m.Options(ice.MSG_USERURL, r.URL.String()) m.Options(ice.MSG_USERWEB, _serve_domain(m), ice.MSG_USERPOD, m.Option(ice.POD)) m.Options(ice.MSG_USERUA, r.Header.Get(html.UserAgent), ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP)) m.Options(ice.MSG_SESSID, kit.Select(m.Option(ice.MSG_SESSID), m.Option(CookieName(m.Option(ice.MSG_USERWEB))))) diff --git a/conf.go b/conf.go index f2dea947..5ac0aa30 100644 --- a/conf.go +++ b/conf.go @@ -222,6 +222,7 @@ const ( // MSG MSG_USERIP = "user.ip" MSG_USERUA = "user.ua" + MSG_USERURL = "user.url" MSG_USERWEB = "user.web" MSG_USERPOD = "user.pod" MSG_USERPOD0 = "user.pod0" diff --git a/core/chat/oauth/client.go b/core/chat/oauth/client.go index 8a129cff..03958211 100644 --- a/core/chat/oauth/client.go +++ b/core/chat/oauth/client.go @@ -158,6 +158,9 @@ func (s Client) Login(m *ice.Message, arg ...string) { func (s Client) Login2(m *ice.Message, arg ...string) { if state, code := m.Option(STATE), m.Option(CODE); !m.WarnNotValid(state == "" || code == "") { msg := m.Spawn() + _msg := m.Cmd("web.chat.oauth.cache", state) + state = kit.Select(state, _msg.Append("state")) + m.Option("goback", _msg.Append("goback")) s.Hash.List(msg, m.Option(mdb.HASH, state)).Table(func(value ice.Maps) { msg.Options(value) }) msg.Options(GRANT_TYPE, AUTHORIZATION_CODE, REDIRECT_URI, s.RedirectURI(msg)).Option(ACCESS_TOKEN, "") if res := s.Get(msg, msg.Option(mdb.HASH), msg.Option(GRANT_URL), kit.Simple(msg.OptionSimple(GRANT_TYPE, CODE), "appid", msg.Option(CLIENT_ID), "secret", msg.Option(CLIENT_SECRET))...); !m.WarnNotValid(res == nil) { diff --git a/core/chat/pod.go b/core/chat/pod.go index f7101e1f..f6e96df6 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -29,7 +29,7 @@ func init() { } else { if msg := m.Cmd(web.SPACE, "20240724-community", "web.chat.oauth.client", "action", "login2"); msg.Option("_arg") != "" { m.RenderResult(kit.Format(template(`document.cookie = "sessid=%s;path=/"; location.href = "%s"; document.cookie = "goback=;path=/;expires=Mon, 19 May 2025 00:52:51 GMT"`), - kit.Simple(msg.Optionv("_arg"))[1], m.Option("goback"))) + kit.Simple(msg.Optionv("_arg"))[1], kit.Select("/s/20240724-enterprise/c/web.team.yingxiaotuiguang.portal", msg.Option("goback"), m.Option("goback")))) return } } diff --git a/misc/wx/agent.go b/misc/wx/agent.go index 6a9fa0be..02594431 100644 --- a/misc/wx/agent.go +++ b/misc/wx/agent.go @@ -53,12 +53,12 @@ func init() { )), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(ACCESS, AGENT).Options(SIGNATURE, _wx_sign(m, m.Option(NONCESTR, ice.Info.Pathname), m.Option(TIMESTAMP, kit.Format(time.Now().Unix())))).Display("") ctx.OptionFromConfig(m, "oauth", nfs.SCRIPT) - if false && m.Option(ice.MSG_USERNAME) == "" { + if m.Option(ice.MSG_USERNAME) == "" { msg := m.Spawn() web.ParseURL(msg, m.Option("oauth")) - state := m.Cmdx("web.chat.oauth.cache", mdb.CREATE, "state", msg.Option("state"), "goback", m.Option(ice.MSG_USERWEB)) - what := kit.MergeURL(m.Option("oauth"), "state", state) - m.Info("what %v", what) + state := m.Cmdx("web.chat.oauth.cache", mdb.CREATE, "state", msg.Option("state"), "goback", kit.Select(m.Option(ice.MSG_USERURL), m.Option(ice.MSG_REFERER))) + oauth := kit.MergeURL(m.Option("oauth"), "state", state) + m.Option("oauth", oauth) } m.Option("oauth", strings.ReplaceAll(m.Option("oauth"), "https%3A%2F%2Fyunxuanlinghang.com", strings.ReplaceAll(m.Option(ice.MSG_USERHOST), "://", "%3A%2F%2F"))) }},