diff --git a/base/web/serve.go b/base/web/serve.go index d4abb3bb..adc9bd81 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -323,6 +323,22 @@ func ServeCmdAction() ice.Actions { func IsLocalHost(m *ice.Message) bool { return (m.R == nil || m.R.Header.Get(html.XForwardedFor) == "") && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) } +func ParseURL(m *ice.Message, p string) []string { + if u, e := url.Parse(p); e == nil { + arg := strings.Split(strings.TrimPrefix(u.Path, nfs.PS), nfs.PS) + for i := 0; i < len(arg); i += 2 { + switch arg[i] { + case "s": + m.Option(ice.POD, kit.Select("", arg, i+1)) + case "c": + m.Option(ice.CMD, kit.Select("", arg, i+1)) + } + } + kit.For(u.Query(), func(k string, v []string) { m.Optionv(k, v) }) + return kit.Split(u.Fragment, ":") + } + return []string{} +} func ParseUA(m *ice.Message) (res []string) { res = append(res, aaa.USERROLE, m.Option(ice.MSG_USERROLE)) res = append(res, aaa.USERNAME, m.Option(ice.MSG_USERNAME)) diff --git a/core/chat/oauth/client.go b/core/chat/oauth/client.go index 6bd9c839..19fac1b2 100644 --- a/core/chat/oauth/client.go +++ b/core/chat/oauth/client.go @@ -112,7 +112,8 @@ func (s Client) User(m *ice.Message, arg ...string) { } m.Info("user info %v", kit.Format(res)) if m.Option(USER_CMD) != "" { - m.Cmdy(kit.Split(m.Option(USER_CMD)), m.OptionSimple("openid"), kit.Simple(res)) + m.Options("open_id", m.Option("openid"), aaa.USERNICK, m.Option("nickname"), aaa.AVATAR, m.Option("headimgurl")) + m.Cmdy(kit.Split(m.Option(USER_CMD)), m.OptionSimple("open_id"), kit.Simple(res)) return } username := m.Option(aaa.USERNAME, m.Option(kit.Select(aaa.USERNAME, m.Option(USER_KEY)))) @@ -167,7 +168,7 @@ func (s Client) Login2(m *ice.Message, arg ...string) { msg.Option(EXPIRES_IN, m.Time(kit.Format("%vs", kit.Int(msg.Option(EXPIRES_IN))))) if s.User(msg, msg.OptionSimple("openid")...); !m.Warn(msg.Option(aaa.USERNAME) == "" && msg.Option("user_uid") == "") { if msg.Option(SESS_CMD) != "" { - m.Cmdy(kit.Split(msg.Option(SESS_CMD)), msg.OptionSimple("user_uid")) + m.Cmdy(kit.Split(msg.Option(SESS_CMD)), kit.Dict("user_uid", msg.Option("user_uid"))) } else { m.ProcessCookie(ice.MSG_SESSID, aaa.SessCreate(m.Message, msg.Option(aaa.USERNAME)), "-2") }