forked from x/icebergs
opt oauth
This commit is contained in:
parent
0a1a28f13e
commit
c81980bd72
@ -139,9 +139,15 @@ func _config_load(m *ice.Message, name string, arg ...string) {
|
|||||||
data, msg := ice.Map{}, m.Spawn(m.Source())
|
data, msg := ice.Map{}, m.Spawn(m.Source())
|
||||||
json.NewDecoder(f).Decode(&data)
|
json.NewDecoder(f).Decode(&data)
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
|
if k == "web.chat.header" {
|
||||||
|
m.Debug("what %v", v)
|
||||||
|
}
|
||||||
msg.Search(k, func(p *ice.Context, s *ice.Context, key string, conf *ice.Config) {
|
msg.Search(k, func(p *ice.Context, s *ice.Context, key string, conf *ice.Config) {
|
||||||
kit.If(s.Configs[key] == nil, func() { s.Configs[key] = &ice.Config{} })
|
kit.If(s.Configs[key] == nil, func() { s.Configs[key] = &ice.Config{} })
|
||||||
s.Configs[key].Value = v
|
s.Configs[key].Value = v
|
||||||
|
if key == "header" {
|
||||||
|
m.Debug("what %v", v)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,12 +216,12 @@ func init() {
|
|||||||
}
|
}
|
||||||
func Save(m *ice.Message, arg ...string) *ice.Message {
|
func Save(m *ice.Message, arg ...string) *ice.Message {
|
||||||
kit.If(len(arg) == 0, func() { arg = kit.SortedKey(m.Target().Configs) })
|
kit.If(len(arg) == 0, func() { arg = kit.SortedKey(m.Target().Configs) })
|
||||||
kit.For(arg, func(i int, k string) { arg[i] = m.Prefix(k) })
|
kit.For(arg, func(i int, k string) { arg[i] = strings.Replace(m.Prefix(k), "/", "", 1) })
|
||||||
return m.Cmd(CONFIG, SAVE, m.Prefix(nfs.JSON), arg)
|
return m.Cmd(CONFIG, SAVE, m.Prefix(nfs.JSON), arg)
|
||||||
}
|
}
|
||||||
func Load(m *ice.Message, arg ...string) *ice.Message {
|
func Load(m *ice.Message, arg ...string) *ice.Message {
|
||||||
kit.If(len(arg) == 0, func() { arg = kit.SortedKey(m.Target().Configs) })
|
kit.If(len(arg) == 0, func() { arg = kit.SortedKey(m.Target().Configs) })
|
||||||
kit.For(arg, func(i int, k string) { arg[i] = m.Prefix(k) })
|
kit.For(arg, func(i int, k string) { arg[i] = strings.Replace(m.Prefix(k), "/", "", 1) })
|
||||||
return m.Cmd(CONFIG, LOAD, m.Prefix(nfs.JSON), arg)
|
return m.Cmd(CONFIG, LOAD, m.Prefix(nfs.JSON), arg)
|
||||||
}
|
}
|
||||||
func ConfAction(arg ...ice.Any) ice.Actions { return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(arg...)} }
|
func ConfAction(arg ...ice.Any) ice.Actions { return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(arg...)} }
|
||||||
|
@ -160,6 +160,8 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands
|
|||||||
}
|
}
|
||||||
case "args":
|
case "args":
|
||||||
m.Cmdy("command", INPUTS, m.Option("index"))
|
m.Cmdy("command", INPUTS, m.Option("index"))
|
||||||
|
case ICON:
|
||||||
|
m.Cmdy("nfs.dir", "usr/icons/", "path")
|
||||||
default:
|
default:
|
||||||
kit.Switch(arg[2],
|
kit.Switch(arg[2],
|
||||||
HASH, func() { _hash_inputs(m, arg[0], arg[1], kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) },
|
HASH, func() { _hash_inputs(m, arg[0], arg[1], kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) },
|
||||||
@ -243,13 +245,11 @@ func init() {
|
|||||||
|
|
||||||
func AutoConfig(arg ...Any) *ice.Action {
|
func AutoConfig(arg ...Any) *ice.Action {
|
||||||
return &ice.Action{Hand: func(m *ice.Message, args ...string) {
|
return &ice.Action{Hand: func(m *ice.Message, args ...string) {
|
||||||
if cs := m.Target().Configs; len(arg) > 0 {
|
if cs := m.Target().Configs; cs[m.CommandKey()] == nil {
|
||||||
if cs[m.CommandKey()] == nil {
|
|
||||||
cs[m.CommandKey()] = &ice.Config{Value: kit.Data(arg...)}
|
cs[m.CommandKey()] = &ice.Config{Value: kit.Data(arg...)}
|
||||||
} else {
|
} else {
|
||||||
kit.For(kit.Dict(arg...), func(k string, v Any) { Config(m, k, v) })
|
kit.For(kit.Dict(arg...), func(k string, v Any) { Config(m, k, v) })
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if cmd := m.Target().Commands[m.CommandKey()]; cmd == nil {
|
if cmd := m.Target().Commands[m.CommandKey()]; cmd == nil {
|
||||||
return
|
return
|
||||||
} else if cmd.Actions[INSERT] != nil {
|
} else if cmd.Actions[INSERT] != nil {
|
||||||
@ -259,7 +259,6 @@ func AutoConfig(arg ...Any) *ice.Action {
|
|||||||
}
|
}
|
||||||
if inputs := []Any{}; cmd.Meta[CREATE] == nil {
|
if inputs := []Any{}; cmd.Meta[CREATE] == nil {
|
||||||
kit.For(kit.Filters(kit.Split(Config(m, SHORT)), TIME, HASH, COUNT), func(k string) { inputs = append(inputs, k) })
|
kit.For(kit.Filters(kit.Split(Config(m, SHORT)), TIME, HASH, COUNT), func(k string) { inputs = append(inputs, k) })
|
||||||
// kit.For(kit.Filters(kit.Split(kit.Select(Config(m, SHORT), Config(m, FIELDS))), TIME, HASH, COUNT), func(k string) { inputs = append(inputs, k) })
|
|
||||||
m.Design(CREATE, "创建", inputs...)
|
m.Design(CREATE, "创建", inputs...)
|
||||||
}
|
}
|
||||||
} else if cmd.Actions[CREATE] != nil {
|
} else if cmd.Actions[CREATE] != nil {
|
||||||
|
@ -157,6 +157,8 @@ func _serve_auth(m *ice.Message, key string, cmds []string, w http.ResponseWrite
|
|||||||
const (
|
const (
|
||||||
SERVE_START = "serve.start"
|
SERVE_START = "serve.start"
|
||||||
|
|
||||||
|
SSO = "sso"
|
||||||
|
URL = "url"
|
||||||
HTTP = "http"
|
HTTP = "http"
|
||||||
HTTPS = "https"
|
HTTPS = "https"
|
||||||
DOMAIN = "domain"
|
DOMAIN = "domain"
|
||||||
@ -215,15 +217,13 @@ func init() {
|
|||||||
sub = kit.Select(P(key, sub), PP(key, sub), strings.HasSuffix(sub, nfs.PS))
|
sub = kit.Select(P(key, sub), PP(key, sub), strings.HasSuffix(sub, nfs.PS))
|
||||||
actions := ice.Actions{}
|
actions := ice.Actions{}
|
||||||
for k, v := range cmd.Actions {
|
for k, v := range cmd.Actions {
|
||||||
if !kit.IsIn(k, ice.CTX_INIT, ice.CTX_EXIT) {
|
kit.If(!kit.IsIn(k, ice.CTX_INIT, ice.CTX_EXIT), func() { actions[k] = v })
|
||||||
actions[k] = v
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c.Commands[sub] = &ice.Command{Name: kit.Select(cmd.Name, action.Name), Actions: ice.MergeActions(actions, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
c.Commands[sub] = &ice.Command{Name: kit.Select(cmd.Name, action.Name), Actions: ice.MergeActions(actions, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
msg := m.Spawn(c, key, cmd)
|
msg := m.Spawn(c, key, cmd)
|
||||||
defer m.Copy(msg)
|
defer m.Copy(msg)
|
||||||
action.Hand(msg, arg...)
|
action.Hand(msg, arg...)
|
||||||
}}
|
}, RawHand: action.Hand}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,11 @@ func _space_fork(m *ice.Message) {
|
|||||||
case CHROME:
|
case CHROME:
|
||||||
m.Go(func() { m.Cmd(SPACE, name, cli.PWD, name) })
|
m.Go(func() { m.Cmd(SPACE, name, cli.PWD, name) })
|
||||||
case LOGIN:
|
case LOGIN:
|
||||||
m.Debug("what %v", m.Option(ice.MSG_USERNAME))
|
|
||||||
if m.Option(ice.MSG_SESSID) != "" && m.Option(ice.MSG_USERNAME) != "" {
|
if m.Option(ice.MSG_SESSID) != "" && m.Option(ice.MSG_USERNAME) != "" {
|
||||||
m.Cmd(SPACE, name, ice.MSG_SESSID, m.Option(ice.MSG_SESSID))
|
m.Cmd(SPACE, name, ice.MSG_SESSID, m.Option(ice.MSG_SESSID))
|
||||||
}
|
}
|
||||||
gdb.Event(m, SPACE_LOGIN, args)
|
gdb.Event(m, SPACE_LOGIN, args)
|
||||||
}
|
}
|
||||||
m.Debug("what %v", m.Option(ice.MSG_USERNAME))
|
|
||||||
_space_handle(m, false, name, c)
|
_space_handle(m, false, name, c)
|
||||||
}, kit.Join(kit.Simple(SPACE, name), lex.SP))
|
}, kit.Join(kit.Simple(SPACE, name), lex.SP))
|
||||||
}
|
}
|
||||||
|
@ -73,12 +73,12 @@ const ACTION = "action"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
web.P(ACTION): {Name: "/action", Help: "工作台", Actions: ice.MergeActions(ice.Actions{
|
ACTION: {Name: "action", Help: "工作台", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg)
|
m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg)
|
||||||
}},
|
}},
|
||||||
web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }},
|
web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }},
|
||||||
}, ctx.CmdAction(), aaa.WhiteAction(web.SHARE, ctx.COMMAND, ice.RUN)), Hand: func(m *ice.Message, arg ...string) {
|
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
|
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -92,5 +92,6 @@ func init() {
|
|||||||
_action_exec(m, arg[0], arg[1], arg[2], arg[3:]...)
|
_action_exec(m, arg[0], arg[1], arg[2], arg[3:]...)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
}, ctx.CmdAction(), aaa.WhiteAction(web.SHARE, ctx.COMMAND, ice.RUN))},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ const FOOTER = "footer"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
web.P(FOOTER): {Name: "/footer", Help: "状态栏", Actions: ice.MergeActions(ice.Actions{
|
FOOTER: {Name: "footer", Help: "状态栏", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
ice.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if aaa.Right(m, arg) {
|
if aaa.Right(m, arg) {
|
||||||
if m.Cmdy(arg); m.IsErrNotFound() {
|
if m.Cmdy(arg); m.IsErrNotFound() {
|
||||||
@ -37,8 +37,9 @@ func init() {
|
|||||||
"help": {Hand: func(m *ice.Message, arg ...string) {
|
"help": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
ctx.ProcessField(m, web.WIKI_WORD, []string{"src/document/" + arg[0] + "/list.shy"}, arg...)
|
ctx.ProcessField(m, web.WIKI_WORD, []string{"src/document/" + arg[0] + "/list.shy"}, arg...)
|
||||||
}},
|
}},
|
||||||
}, ctx.CmdAction(), aaa.WhiteAction(ctx.COMMAND, ice.RUN)), Hand: func(m *ice.Message, arg ...string) {
|
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Result(kit.Select(mdb.Config(m, TITLE), ice.Info.Make.Email))
|
m.Result(kit.Select(mdb.Config(m, TITLE), ice.Info.Make.Email))
|
||||||
}},
|
}},
|
||||||
|
}, ctx.CmdAction(), aaa.WhiteAction(ctx.COMMAND, ice.RUN))},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,8 @@ const HEADER = "header"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
web.P(HEADER): {Name: "/header", Help: "标题栏", Actions: ice.MergeActions(ice.Actions{
|
HEADER: {Name: "header", Help: "标题栏", Actions: ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, HEADER) }},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, HEADER) }},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {}},
|
|
||||||
aaa.LOGIN: {Hand: func(m *ice.Message, arg ...string) {}},
|
aaa.LOGIN: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||||
aaa.LOGOUT: {Hand: aaa.SessLogout},
|
aaa.LOGOUT: {Hand: aaa.SessLogout},
|
||||||
aaa.PASSWORD: {Hand: _header_users},
|
aaa.PASSWORD: {Hand: _header_users},
|
||||||
@ -79,21 +78,20 @@ func init() {
|
|||||||
aaa.LANGUAGE: {Hand: _header_users},
|
aaa.LANGUAGE: {Hand: _header_users},
|
||||||
aaa.BACKGROUND: {Hand: _header_users},
|
aaa.BACKGROUND: {Hand: _header_users},
|
||||||
aaa.AVATAR: {Hand: _header_users},
|
aaa.AVATAR: {Hand: _header_users},
|
||||||
web.SHARE: {Hand: _header_share},
|
aaa.THEME: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
"webpack": {Hand: ctx.CmdHandler("webpack", "build")},
|
if tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||||
"email": {Name: "email to subject content", Hand: func(m *ice.Message, arg ...string) {
|
m.Cmd(cli.SYSTEM, "osascript", "-e", `tell app "System Events" to tell appearance preferences to set dark mode to `+
|
||||||
|
kit.Select(ice.TRUE, ice.FALSE, kit.IsIn(kit.Select(html.LIGHT, arg, 0), html.LIGHT, html.WHITE)))
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
aaa.EMAIL: {Name: "email to subject content", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Options("volcano", web.UserHost(m), "version", web.RenderVersion(m))
|
m.Options("volcano", web.UserHost(m), "version", web.RenderVersion(m))
|
||||||
m.Option(ice.MSG_USERWEB, kit.MergeURL(m.Option(ice.MSG_USERWEB), web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN)))
|
m.Option(ice.MSG_USERWEB, kit.MergeURL(m.Option(ice.MSG_USERWEB), web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN)))
|
||||||
m.Cmdy(aaa.EMAIL, aaa.SEND, arg, aaa.CONTENT, nfs.Template(m, "email.html"))
|
m.Cmdy(aaa.EMAIL, aaa.SEND, arg, aaa.CONTENT, nfs.Template(m, "email.html"))
|
||||||
}},
|
}},
|
||||||
"theme": {Hand: func(m *ice.Message, arg ...string) {
|
web.SHARE: {Hand: _header_share},
|
||||||
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
"webpack": {Hand: ctx.CmdHandler("webpack", "build")},
|
||||||
return
|
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
}
|
|
||||||
m.Cmd(cli.SYSTEM, "osascript", "-e", `tell app "System Events" to tell appearance preferences to set dark mode to `+
|
|
||||||
kit.Select(ice.TRUE, ice.FALSE, kit.IsIn(kit.Select(html.LIGHT, arg, 0), html.LIGHT, html.WHITE)))
|
|
||||||
}},
|
|
||||||
}, ctx.ConfAction(SSO, "")), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Option("language.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.LANGUAGE), nfs.FILE).Appendv(nfs.FILE))
|
m.Option("language.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.LANGUAGE), nfs.FILE).Appendv(nfs.FILE))
|
||||||
m.Option("theme.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.THEME), nfs.FILE).Appendv(nfs.FILE))
|
m.Option("theme.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.THEME), nfs.FILE).Appendv(nfs.FILE))
|
||||||
m.Option("spide.hub", m.Cmdv(web.SPIDE, ice.HUB, web.CLIENT_URL))
|
m.Option("spide.hub", m.Cmdv(web.SPIDE, ice.HUB, web.CLIENT_URL))
|
||||||
@ -104,7 +102,9 @@ func init() {
|
|||||||
kit.For([]string{aaa.USERNICK, aaa.LANGUAGE, aaa.EMAIL}, func(k string) { m.Option(k, msg.Append(k)) })
|
kit.For([]string{aaa.USERNICK, aaa.LANGUAGE, aaa.EMAIL}, func(k string) { m.Option(k, msg.Append(k)) })
|
||||||
kit.For([]string{aaa.AVATAR, aaa.BACKGROUND}, func(k string) { m.Option(k, web.RequireFile(m, msg.Append(k))) })
|
kit.For([]string{aaa.AVATAR, aaa.BACKGROUND}, func(k string) { m.Option(k, web.RequireFile(m, msg.Append(k))) })
|
||||||
kit.If(m.Option(aaa.LANGUAGE) == "", func() { m.Option(aaa.LANGUAGE, kit.Split(m.R.Header.Get(web.AcceptLanguage), ",;")[0]) })
|
kit.If(m.Option(aaa.LANGUAGE) == "", func() { m.Option(aaa.LANGUAGE, kit.Split(m.R.Header.Get(web.AcceptLanguage), ",;")[0]) })
|
||||||
m.Echo(mdb.Config(m, TITLE)).Option(MENUS, mdb.Config(m, MENUS))
|
m.Option(MENUS, mdb.Config(m, MENUS))
|
||||||
|
m.Echo(mdb.Config(m, TITLE))
|
||||||
|
}},
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,9 @@ const (
|
|||||||
GRANT_TYPE = "grant_type"
|
GRANT_TYPE = "grant_type"
|
||||||
STATE = "state"
|
STATE = "state"
|
||||||
CODE = "code"
|
CODE = "code"
|
||||||
API = "api"
|
|
||||||
|
|
||||||
|
API_PREFIX = "api_prefix"
|
||||||
|
TOKEN_PREFIX = "token_prefix"
|
||||||
ACCESS_TOKEN = "access_token"
|
ACCESS_TOKEN = "access_token"
|
||||||
EXPIRES_IN = "expires_in"
|
EXPIRES_IN = "expires_in"
|
||||||
)
|
)
|
||||||
@ -37,18 +38,16 @@ const (
|
|||||||
type Client struct {
|
type Client struct {
|
||||||
ice.Hash
|
ice.Hash
|
||||||
short string `data:"domain,client_id"`
|
short string `data:"domain,client_id"`
|
||||||
field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,api,prefix"`
|
field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,api_prefix,token_prefix"`
|
||||||
|
sso string `name:"sso name* icon*" help:"登录"`
|
||||||
auth string `name:"auth" help:"授权"`
|
auth string `name:"auth" help:"授权"`
|
||||||
user string `name:"user" help:"用户"`
|
user string `name:"user" help:"用户"`
|
||||||
orgs string `name:"orgs" help:"组织"`
|
orgs string `name:"orgs" help:"组织"`
|
||||||
repo string `name:"repo" help:"源码"`
|
repo string `name:"repo" help:"源码"`
|
||||||
list string `name:"list hash auto" help:"授权"`
|
list string `name:"list hash auto" help:"授权"`
|
||||||
|
login string `name:"login" role:"void"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Client) Init(m *ice.Message, arg ...string) {
|
|
||||||
aaa.White(m.Message, m.PrefixKey(), ctx.ACTION, aaa.LOGIN)
|
|
||||||
s.Hash.Init(m, arg...)
|
|
||||||
}
|
|
||||||
func (s Client) Inputs(m *ice.Message, arg ...string) {
|
func (s Client) Inputs(m *ice.Message, arg ...string) {
|
||||||
switch s.Hash.Inputs(m, arg...); arg[0] {
|
switch s.Hash.Inputs(m, arg...); arg[0] {
|
||||||
case web.DOMAIN:
|
case web.DOMAIN:
|
||||||
@ -62,12 +61,16 @@ func (s Client) Inputs(m *ice.Message, arg ...string) {
|
|||||||
m.Push(arg[0], "/login/oauth/access_token")
|
m.Push(arg[0], "/login/oauth/access_token")
|
||||||
case USERS_URL:
|
case USERS_URL:
|
||||||
m.Push(arg[0], "/api/v1/user")
|
m.Push(arg[0], "/api/v1/user")
|
||||||
case lex.PREFIX:
|
case API_PREFIX:
|
||||||
m.Push(arg[0], "token")
|
|
||||||
case API:
|
|
||||||
m.Push(arg[0], "/api/v1/")
|
m.Push(arg[0], "/api/v1/")
|
||||||
|
case TOKEN_PREFIX:
|
||||||
|
m.Push(arg[0], "token")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (s Client) Sso(m *ice.Message, arg ...string) {
|
||||||
|
mdb.Conf(m, "web.chat.header", kit.Keym(web.SSO, m.Option(mdb.NAME), web.URL), kit.MergeURL2(m.Option(web.DOMAIN), m.Option(OAUTH_URL), m.OptionSimple(CLIENT_ID), REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, m.Option(mdb.HASH)))
|
||||||
|
mdb.Conf(m, "web.chat.header", kit.Keym(web.SSO, m.Option(mdb.NAME), mdb.ICON), m.Option(mdb.ICON))
|
||||||
|
}
|
||||||
func (s Client) Auth(m *ice.Message, arg ...string) {
|
func (s Client) Auth(m *ice.Message, arg ...string) {
|
||||||
m.Options(REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, m.Option(mdb.HASH))
|
m.Options(REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, m.Option(mdb.HASH))
|
||||||
m.ProcessOpen(kit.MergeURL2(m.Option(web.DOMAIN), m.Option(OAUTH_URL), m.OptionSimple(CLIENT_ID, REDIRECT_URI, RESPONSE_TYPE, STATE)))
|
m.ProcessOpen(kit.MergeURL2(m.Option(web.DOMAIN), m.Option(OAUTH_URL), m.OptionSimple(CLIENT_ID, REDIRECT_URI, RESPONSE_TYPE, STATE)))
|
||||||
@ -79,18 +82,10 @@ func (s Client) User(m *ice.Message, arg ...string) {
|
|||||||
m.OptionSimple(aaa.EMAIL, aaa.LANGUAGE, aaa.AVATAR_URL))
|
m.OptionSimple(aaa.EMAIL, aaa.LANGUAGE, aaa.AVATAR_URL))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s Client) Sso(m *ice.Message, arg ...string) {
|
|
||||||
mdb.Conf(m, "web.chat.header", kit.Keym("sso.gitea.url"), kit.MergeURL2(m.Option(web.DOMAIN), m.Option(OAUTH_URL), m.OptionSimple(CLIENT_ID), REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, m.Option(mdb.HASH)))
|
|
||||||
mdb.Conf(m, "web.chat.header", kit.Keym("sso.gitea.icon"), "usr/icons/gitea.png")
|
|
||||||
}
|
|
||||||
func (s Client) Orgs(m *ice.Message, arg ...string) {}
|
func (s Client) Orgs(m *ice.Message, arg ...string) {}
|
||||||
func (s Client) Repo(m *ice.Message, arg ...string) {}
|
func (s Client) Repo(m *ice.Message, arg ...string) {}
|
||||||
func (s Client) List(m *ice.Message, arg ...string) {
|
func (s Client) List(m *ice.Message, arg ...string) {
|
||||||
if s.Hash.List(m, arg...).PushAction(s.Sso, s.User, s.Auth, s.Remove); len(arg) == 0 {
|
s.Hash.List(m, arg...).PushAction(s.User, s.Auth, s.Sso, s.Remove).EchoScript(s.RedirectURI(m))
|
||||||
m.EchoScript(s.RedirectURI(m))
|
|
||||||
} else {
|
|
||||||
m.EchoScript("config header sso " + kit.MergeURL2(m.Append(web.DOMAIN), m.Append(OAUTH_URL), m.AppendSimple(CLIENT_ID), REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, arg[0]))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.ChatCtxCmd(Client{}) }
|
func init() { ice.ChatCtxCmd(Client{}) }
|
||||||
@ -131,8 +126,8 @@ func (s Client) Delete(m *ice.Message, hash, api string, arg ...string) ice.Any
|
|||||||
func (s Client) request(m *ice.Message, hash, api string, arg ...string) []string {
|
func (s Client) request(m *ice.Message, hash, api string, arg ...string) []string {
|
||||||
msg := s.Hash.List(m.Spawn(), hash)
|
msg := s.Hash.List(m.Spawn(), hash)
|
||||||
kit.If(msg.Append(ACCESS_TOKEN), func(p string) {
|
kit.If(msg.Append(ACCESS_TOKEN), func(p string) {
|
||||||
m.Options(web.SPIDE_HEADER, ice.Maps{web.Authorization: msg.Append(lex.PREFIX) + lex.SP + p})
|
m.Options(web.SPIDE_HEADER, ice.Maps{web.Authorization: msg.Append(TOKEN_PREFIX) + lex.SP + p})
|
||||||
})
|
})
|
||||||
kit.If(api == "", func() { api = path.Join(msg.Append(API), strings.ToLower(kit.FuncName(6))) })
|
kit.If(api == "", func() { api = path.Join(msg.Append(API_PREFIX), strings.ToLower(kit.FuncName(6))) })
|
||||||
return kit.Simple(kit.MergeURL2(msg.Append(web.DOMAIN), api), arg)
|
return kit.Simple(kit.MergeURL2(msg.Append(web.DOMAIN), api), arg)
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ const RIVER = "river"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
web.P(RIVER): {Name: "/river", Help: "群组", Actions: ice.MergeActions(ice.Actions{
|
RIVER: {Name: "river", Help: "群组", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashImport(m) }},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashImport(m) }},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }},
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -66,7 +66,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg)
|
gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg)
|
||||||
}},
|
}},
|
||||||
}, aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template")), Hand: func(m *ice.Message, arg ...string) {
|
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) {
|
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) {
|
||||||
return
|
return
|
||||||
} else if len(arg) == 0 {
|
} else if len(arg) == 0 {
|
||||||
@ -77,5 +77,6 @@ func init() {
|
|||||||
m.Cmdy(arg[2], arg[3:], kit.Dict(ice.MSG_RIVER, arg[0], ice.MSG_STORM, arg[1]))
|
m.Cmdy(arg[2], arg[3:], kit.Dict(ice.MSG_RIVER, arg[0], ice.MSG_STORM, arg[1]))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
}, aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template"))},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,11 @@ const SEARCH = "search"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
web.P(SEARCH): {Name: "/search", Help: "搜索框", Actions: ice.MergeActions(ice.Actions{
|
SEARCH: {Name: "search", Help: "搜索框", Actions: ice.MergeActions(ice.Actions{
|
||||||
cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }},
|
cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }},
|
||||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(web.Space(m, m.Option(ice.POD)), mdb.SEARCH, arg).StatusTimeCount()
|
m.Cmdy(web.Space(m, m.Option(ice.POD)), mdb.SEARCH, arg).StatusTimeCount()
|
||||||
}},
|
}},
|
||||||
|
}, ctx.CmdAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user