mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
mac pro aaa
This commit is contained in:
parent
cf5b72facc
commit
c29800b184
16
etc/init.shy
16
etc/init.shy
@ -1,19 +1,7 @@
|
||||
~shell1
|
||||
login root root
|
||||
source etc/local.shy
|
||||
var a <-
|
||||
for index $a result hi
|
||||
echo $hi
|
||||
end
|
||||
|
||||
~file1
|
||||
history load etc/history.txt
|
||||
~shell1
|
||||
alias import nfs
|
||||
|
||||
var b = 1
|
||||
|
||||
label hi
|
||||
|
||||
echo $b
|
||||
let b = $b + 1
|
||||
goto hi $b < 4
|
||||
|
||||
|
@ -3,12 +3,14 @@ package aaa // {{{
|
||||
import ( // {{{
|
||||
"contexts"
|
||||
|
||||
"bufio"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"crypto"
|
||||
"crypto/md5"
|
||||
"strings"
|
||||
|
||||
crand "crypto/rand"
|
||||
"crypto/rsa"
|
||||
@ -27,79 +29,57 @@ import ( // {{{
|
||||
// }}}
|
||||
|
||||
type AAA struct {
|
||||
share map[string]*ctx.Context
|
||||
sessions map[string]*ctx.Context
|
||||
sessions map[string]*ctx.Message
|
||||
*ctx.Context
|
||||
}
|
||||
|
||||
func (aaa *AAA) Session(meta string) string { // {{{
|
||||
bs := md5.Sum([]byte(fmt.Sprintln("%d%d%s", time.Now().Unix(), rand.Int(), meta)))
|
||||
sessid := hex.EncodeToString(bs[:])
|
||||
return sessid
|
||||
return hex.EncodeToString(bs[:])
|
||||
}
|
||||
|
||||
// }}}
|
||||
func (aaa *AAA) Password(pwd string) string { // {{{
|
||||
bs := md5.Sum([]byte(fmt.Sprintln("用户密码:%s", pwd)))
|
||||
return hex.EncodeToString(bs[:])
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
func (aaa *AAA) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server { // {{{
|
||||
c.Caches = map[string]*ctx.Cache{}
|
||||
c.Configs = map[string]*ctx.Config{}
|
||||
|
||||
c.Index = map[string]*ctx.Context{
|
||||
"void": &ctx.Context{Name: "void", Help: "void",
|
||||
Caches: map[string]*ctx.Cache{"group": &ctx.Cache{}},
|
||||
Configs: map[string]*ctx.Config{"rootname": &ctx.Config{}},
|
||||
Commands: map[string]*ctx.Command{"login": &ctx.Command{}},
|
||||
},
|
||||
}
|
||||
|
||||
s := new(AAA)
|
||||
s.Context = c
|
||||
return s
|
||||
}
|
||||
|
||||
// }}}
|
||||
func (aaa *AAA) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
|
||||
aaa.Caches["group"] = &ctx.Cache{Name: "用户组", Value: "", Help: "用户组"}
|
||||
aaa.Caches["username"] = &ctx.Cache{Name: "用户名", Value: "", Help: "用户名"}
|
||||
aaa.Caches["password"] = &ctx.Cache{Name: "用户密码", Value: "", Help: "用户密码,加密存储", Hand: func(m *ctx.Message, x *ctx.Cache, arg ...string) string {
|
||||
if len(arg) > 0 {
|
||||
bs := md5.Sum([]byte(fmt.Sprintln("用户密码:%s", arg[0])))
|
||||
m.Assert(x.Value == "" || x.Value == hex.EncodeToString(bs[:]), "密码错误")
|
||||
m.Cap("expire", fmt.Sprintf("%d", time.Now().Unix()+int64(Pulse.Confi("expire"))))
|
||||
return hex.EncodeToString(bs[:])
|
||||
}
|
||||
return x.Value
|
||||
}}
|
||||
|
||||
aaa.Caches["sessid"] = &ctx.Cache{Name: "会话令牌", Value: "", Help: "用户的会话标识"}
|
||||
aaa.Caches["expire"] = &ctx.Cache{Name: "会话超时", Value: "", Help: "用户的会话标识"}
|
||||
aaa.Caches["time"] = &ctx.Cache{Name: "登录时间", Value: fmt.Sprintf("%d", time.Now().Unix()), Help: "用户登录时间", Hand: func(m *ctx.Message, x *ctx.Cache, arg ...string) string {
|
||||
if len(arg) > 0 {
|
||||
c.Caches = map[string]*ctx.Cache{
|
||||
"time": &ctx.Cache{Name: "time", Value: fmt.Sprintf("%d", time.Now().Unix()), Help: "登录时间", Hand: func(m *ctx.Message, x *ctx.Cache, arg ...string) string {
|
||||
if len(arg) > 0 { // {{{
|
||||
return arg[0]
|
||||
}
|
||||
|
||||
n, e := strconv.Atoi(x.Value)
|
||||
m.Assert(e)
|
||||
return time.Unix(int64(n), 0).Format("15:03:04")
|
||||
}}
|
||||
|
||||
if m.Target() == Index {
|
||||
Pulse = m
|
||||
// }}}
|
||||
}},
|
||||
"username": &ctx.Cache{Name: "username", Value: arg[0], Help: "用户名"},
|
||||
"password": &ctx.Cache{Name: "password", Value: arg[1], Help: "用户密码,加密存储"},
|
||||
"sessid": &ctx.Cache{Name: "sessid", Value: arg[2], Help: "会话令牌"},
|
||||
"expire": &ctx.Cache{Name: "expire", Value: fmt.Sprintf("%d", int64(m.Confi("expire"))+time.Now().Unix()), Help: "会话超时"},
|
||||
}
|
||||
c.Configs = map[string]*ctx.Config{}
|
||||
|
||||
s := new(AAA)
|
||||
s.Context = c
|
||||
s.sessions = aaa.sessions
|
||||
return s
|
||||
}
|
||||
|
||||
// }}}
|
||||
func (aaa *AAA) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
|
||||
return aaa
|
||||
}
|
||||
|
||||
// }}}
|
||||
func (aaa *AAA) Start(m *ctx.Message, arg ...string) bool { // {{{
|
||||
if len(arg) > 1 && m.Cap("sessid") == "" {
|
||||
m.Cap("group", arg[0])
|
||||
m.Cap("username", arg[1])
|
||||
m.Cap("stream", m.Cap("username"))
|
||||
m.Cap("sessid", aaa.Session(arg[1]))
|
||||
Pulse.Capi("nuser", 1)
|
||||
}
|
||||
|
||||
m.Log("info", "%s login %s %s", Pulse.Cap("nuser"), m.Cap("group"), m.Cap("username"))
|
||||
aaa.sessions[m.Cap("sessid")] = m
|
||||
m.Log("info", "%d login %s", m.Capi("nuser", 1), m.Cap("stream", arg[0]))
|
||||
return false
|
||||
}
|
||||
|
||||
@ -107,12 +87,13 @@ func (aaa *AAA) Start(m *ctx.Message, arg ...string) bool { // {{{
|
||||
func (aaa *AAA) Close(m *ctx.Message, arg ...string) bool { // {{{
|
||||
switch aaa.Context {
|
||||
case m.Target():
|
||||
root := Pulse.Target().Server.(*AAA)
|
||||
delete(root.sessions, m.Cap("sessid"))
|
||||
m.Log("info", "%d logout %s", Pulse.Capi("nuser", -1)+1, m.Cap("username"))
|
||||
if int64(m.Capi("expire")) > time.Now().Unix() {
|
||||
return false
|
||||
}
|
||||
delete(aaa.sessions, m.Cap("sessid"))
|
||||
m.Log("info", "%d logout %s", m.Capi("nuser", -1), m.Cap("username"))
|
||||
case m.Source():
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@ -121,89 +102,70 @@ func (aaa *AAA) Close(m *ctx.Message, arg ...string) bool { // {{{
|
||||
var Pulse *ctx.Message
|
||||
var Index = &ctx.Context{Name: "aaa", Help: "认证中心",
|
||||
Caches: map[string]*ctx.Cache{
|
||||
"nuser": &ctx.Cache{Name: "用户数量", Value: "0", Help: "用户数量"},
|
||||
"nuser": &ctx.Cache{Name: "nuser", Value: "0", Help: "用户数量"},
|
||||
},
|
||||
Configs: map[string]*ctx.Config{
|
||||
"rootname": &ctx.Config{Name: "根用户名", Value: "root", Help: "根用户名"},
|
||||
"expire": &ctx.Config{Name: "会话超时(s)", Value: "7200", Help: "会话超时"},
|
||||
"cert": &ctx.Config{Name: "证书文件", Value: "etc/cert.pem", Help: "证书文件"},
|
||||
"key": &ctx.Config{Name: "私钥文件", Value: "etc/key.pem", Help: "私钥文件"},
|
||||
"rootname": &ctx.Config{Name: "rootname", Value: "root", Help: "根用户名"},
|
||||
"expire": &ctx.Config{Name: "expire(s)", Value: "7200", Help: "会话超时"},
|
||||
"cert": &ctx.Config{Name: "cert", Value: "etc/cert.pem", Help: "证书文件"},
|
||||
"key": &ctx.Config{Name: "key", Value: "etc/key.pem", Help: "私钥文件"},
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"login": &ctx.Command{Name: "login [sessid]|[[group] username password]]", Help: "用户登录", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
// m.Target(c) // {{{
|
||||
aaa := c.Server.(*AAA)
|
||||
|
||||
"login": &ctx.Command{
|
||||
Name: "login [sessid]|[username password]|[load|save filename]",
|
||||
Help: "用户登录, sessid: 会话ID, username: 用户名, password: 密码, load: 加载用户信息, save: 保存用户信息, filename: 文件名",
|
||||
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
if aaa, ok := m.Target().Server.(*AAA); m.Assert(ok) { // {{{
|
||||
switch len(arg) {
|
||||
case 0:
|
||||
m.Travel(func(m *ctx.Message, i int) bool {
|
||||
m.Echo("%s(%s): %s\n", m.Target().Name, m.Cap("group"), m.Cap("time"))
|
||||
if int64(m.Capi("expire")) < time.Now().Unix() {
|
||||
m.Target().Close(m)
|
||||
if i > 0 {
|
||||
m.Echo("%s: %s\n", m.Cap("username"), m.Cap("sessid"))
|
||||
}
|
||||
return true
|
||||
}, c)
|
||||
})
|
||||
case 1:
|
||||
_, ok := aaa.sessions[arg[0]]
|
||||
m.Assert(ok, "会话失败")
|
||||
// m.Target(s)
|
||||
m.Assert(int64(m.Capi("expire")) > time.Now().Unix(), "会话失败")
|
||||
|
||||
m.Log("info", "logon %s %s", m.Cap("username"), m.Cap("group"))
|
||||
m.Echo(m.Cap("username"))
|
||||
|
||||
m.Append("username", m.Cap("username"))
|
||||
m.Append("userrole", m.Cap("group"))
|
||||
m.Appendv("aaa", m)
|
||||
m.Sess("aaa", m)
|
||||
case 2, 3:
|
||||
group, username, password := arg[0], arg[0], arg[1]
|
||||
if len(arg) == 3 {
|
||||
username, password = arg[1], arg[2]
|
||||
}
|
||||
|
||||
msg := m
|
||||
if username == Pulse.Conf("rootname") {
|
||||
msg = Pulse.Spawn(Pulse.Target())
|
||||
msg.Set("detail", group, username).Target().Start(msg)
|
||||
} else if msg = Pulse.Find(username, false); msg == nil {
|
||||
m.Start(username, "认证用户", group, username)
|
||||
msg = m
|
||||
if msg, ok := aaa.sessions[arg[0]]; ok {
|
||||
if int64(msg.Capi("expire")) > time.Now().Unix() {
|
||||
m.Echo(msg.Cap("username"))
|
||||
m.Copy(msg, "target")
|
||||
} else {
|
||||
// m.Target(msg.Target())
|
||||
delete(aaa.sessions, arg[0])
|
||||
msg.Target().Close(msg)
|
||||
m.Capi("nuser", -1)
|
||||
}
|
||||
|
||||
msg.Cap("password", password)
|
||||
|
||||
aaa.sessions[m.Cap("sessid")] = msg.Target()
|
||||
m.Echo(msg.Cap("sessid"))
|
||||
|
||||
m.Append("username", msg.Cap("username"))
|
||||
m.Append("userrole", msg.Cap("group"))
|
||||
m.Appendv("aaa", msg)
|
||||
m.Sess("aaa", msg)
|
||||
}
|
||||
// }}}
|
||||
}},
|
||||
"share": &ctx.Command{Name: "share user", Help: "用户登录", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
if len(arg) == 0 { // {{{
|
||||
aaa := m.Target().Server.(*AAA)
|
||||
for k, v := range aaa.share {
|
||||
m.Echo("%s: %s", k, v.Name)
|
||||
default:
|
||||
switch arg[0] {
|
||||
case "load":
|
||||
if f, e := os.Open(arg[1]); m.Assert(e) {
|
||||
for bio := bufio.NewScanner(f); bio.Scan(); {
|
||||
word := strings.SplitN(bio.Text(), ":", 3)
|
||||
m.Spawn().Start(word[0], "用户", word[0], word[1], word[2])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
group := m.Sess("aaa").Cap("group")
|
||||
m.Travel(func(msg *ctx.Message, i int) bool {
|
||||
aaa := msg.Target().Server.(*AAA)
|
||||
if aaa.share == nil {
|
||||
aaa.share = make(map[string]*ctx.Context)
|
||||
case "save":
|
||||
if f, e := os.Create(arg[1]); m.Assert(e) {
|
||||
m.Travel(func(m *ctx.Message, i int) bool {
|
||||
if i > 0 {
|
||||
f.WriteString(fmt.Sprintf("%s:%s:%s\n", m.Cap("username"), m.Cap("password"), m.Cap("sessid")))
|
||||
}
|
||||
aaa.share[group] = m.Target()
|
||||
return true
|
||||
}, c)
|
||||
// }}}
|
||||
})
|
||||
}
|
||||
default:
|
||||
if msg := m.Find(arg[0], false); msg == nil {
|
||||
m.Start(arg[0], "用户", arg[0], aaa.Password(arg[1]), aaa.Session(arg[0]))
|
||||
m.Echo(m.Cap("sessid"))
|
||||
} else if msg.Cap("password") != aaa.Password(arg[1]) {
|
||||
return
|
||||
} else {
|
||||
m.Echo(msg.Cap("sessid"))
|
||||
m.Copy(msg, "target")
|
||||
}
|
||||
}
|
||||
}
|
||||
} // }}}
|
||||
}},
|
||||
"md5": &ctx.Command{Name: "md5 [file filename][content]", Help: "散列",
|
||||
Form: map[string]int{"file": 1},
|
||||
@ -368,16 +330,6 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心",
|
||||
// }}}
|
||||
}},
|
||||
},
|
||||
Index: map[string]*ctx.Context{
|
||||
"void": &ctx.Context{Name: "void", Help: "void",
|
||||
Caches: map[string]*ctx.Cache{"group": &ctx.Cache{}},
|
||||
Configs: map[string]*ctx.Config{"rootname": &ctx.Config{}},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"login": &ctx.Command{},
|
||||
"check": &ctx.Command{},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -385,5 +337,5 @@ func init() {
|
||||
aaa.Context = Index
|
||||
ctx.Index.Register(Index, aaa)
|
||||
|
||||
aaa.sessions = make(map[string]*ctx.Context)
|
||||
aaa.sessions = make(map[string]*ctx.Message)
|
||||
}
|
||||
|
@ -113,7 +113,6 @@ func (cli *CLI) Start(m *ctx.Message, arg ...string) bool { // {{{
|
||||
yac.Cmd("train", "exp", "exp", "val", "rep{", "op2", "val", "}")
|
||||
yac.Cmd("train", "val", "val", "opt{", "op1", "}", "(", "exp", ")")
|
||||
|
||||
yac.Cmd("train", "stm", "var", "cache", "key", "opt{", "=", "exp", "}")
|
||||
yac.Cmd("train", "stm", "var", "var", "key", "opt{", "=", "exp", "}")
|
||||
yac.Cmd("train", "stm", "let", "let", "key", "opt{", "=", "exp", "}")
|
||||
yac.Cmd("train", "stm", "var", "var", "key", "<-")
|
||||
@ -543,7 +542,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
m.Echo(result)
|
||||
// }}}
|
||||
}},
|
||||
"exp": &ctx.Command{Name: "exp word", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
"exp": &ctx.Command{Name: "exp word", Help: "表达式运算", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
pre := map[string]int{ // {{{
|
||||
"=": 1,
|
||||
"+": 2, "-": 2,
|
||||
@ -736,6 +735,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
}
|
||||
// }}}
|
||||
}},
|
||||
"login": &ctx.Command{Name: "login username password", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
m.Sess("aaa", false).Cmd("login", arg[0], arg[1])
|
||||
}},
|
||||
"clear": &ctx.Command{Name: "clear", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
m.Log("fuck", strings.Repeat("\n", 20))
|
||||
}},
|
||||
|
@ -275,7 +275,7 @@ type Message struct {
|
||||
Data map[string]interface{}
|
||||
|
||||
callback func(msg *Message) (sub *Message)
|
||||
sessions map[string]*Message
|
||||
Sessions map[string]*Message
|
||||
|
||||
messages []*Message
|
||||
message *Message
|
||||
@ -327,12 +327,12 @@ func (m *Message) Copy(msg *Message, meta string, arg ...string) *Message { // {
|
||||
m.callback = msg.callback
|
||||
case "session":
|
||||
if len(arg) == 0 {
|
||||
for k, v := range msg.sessions {
|
||||
m.sessions[k] = v
|
||||
for k, v := range msg.Sessions {
|
||||
m.Sessions[k] = v
|
||||
}
|
||||
} else {
|
||||
for _, k := range arg {
|
||||
m.sessions[k] = msg.sessions[k]
|
||||
m.Sessions[k] = msg.Sessions[k]
|
||||
}
|
||||
}
|
||||
case "detail", "result":
|
||||
@ -567,18 +567,18 @@ func (m *Message) Search(key string, root ...bool) []*Message { // {{{
|
||||
// }}}
|
||||
func (m *Message) Sess(key string, arg ...interface{}) *Message { // {{{
|
||||
spawn := true
|
||||
if _, ok := m.sessions[key]; !ok && len(arg) > 0 {
|
||||
if m.sessions == nil {
|
||||
m.sessions = make(map[string]*Message)
|
||||
if _, ok := m.Sessions[key]; !ok && len(arg) > 0 {
|
||||
if m.Sessions == nil {
|
||||
m.Sessions = make(map[string]*Message)
|
||||
}
|
||||
|
||||
switch value := arg[0].(type) {
|
||||
case *Message:
|
||||
m.sessions[key] = value
|
||||
return m.sessions[key]
|
||||
m.Sessions[key] = value
|
||||
return m.Sessions[key]
|
||||
case *Context:
|
||||
m.sessions[key] = m.Spawn(value)
|
||||
return m.sessions[key]
|
||||
m.Sessions[key] = m.Spawn(value)
|
||||
return m.Sessions[key]
|
||||
case string:
|
||||
root := true
|
||||
if len(arg) > 2 {
|
||||
@ -600,18 +600,18 @@ func (m *Message) Sess(key string, arg ...interface{}) *Message { // {{{
|
||||
|
||||
switch method {
|
||||
case "find":
|
||||
m.sessions[key] = m.Find(value, root)
|
||||
m.Sessions[key] = m.Find(value, root)
|
||||
case "search":
|
||||
m.sessions[key] = m.Search(value, root)[0]
|
||||
m.Sessions[key] = m.Search(value, root)[0]
|
||||
}
|
||||
return m.sessions[key]
|
||||
return m.Sessions[key]
|
||||
case bool:
|
||||
spawn = value
|
||||
}
|
||||
}
|
||||
|
||||
for msg := m; msg != nil; msg = msg.message {
|
||||
if x, ok := msg.sessions[key]; ok {
|
||||
if x, ok := msg.Sessions[key]; ok {
|
||||
if spawn {
|
||||
x = m.Spawn(x.target)
|
||||
}
|
||||
@ -1573,7 +1573,7 @@ var CGI = template.FuncMap{
|
||||
case "messages":
|
||||
case "sessions":
|
||||
msg := []string{}
|
||||
for k, _ := range m.sessions {
|
||||
for k, _ := range m.Sessions {
|
||||
msg = append(msg, fmt.Sprintf("%s", k))
|
||||
}
|
||||
return strings.Join(msg, " ")
|
||||
@ -1613,7 +1613,7 @@ var CGI = template.FuncMap{
|
||||
return strings.Join(msg, " ")
|
||||
case "sessions":
|
||||
msg := []string{}
|
||||
for k, _ := range m.sessions {
|
||||
for k, _ := range m.Sessions {
|
||||
msg = append(msg, fmt.Sprintf("%s", k))
|
||||
}
|
||||
return strings.Join(msg, " ")
|
||||
@ -2001,9 +2001,9 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
}
|
||||
}
|
||||
|
||||
if len(msg.sessions) > 0 {
|
||||
m.Color(31, "sessions(%d):\n", len(msg.sessions))
|
||||
for k, v := range msg.sessions {
|
||||
if len(msg.Sessions) > 0 {
|
||||
m.Color(31, "sessions(%d):\n", len(msg.Sessions))
|
||||
for k, v := range msg.Sessions {
|
||||
m.Echo(" %s %s\n", k, v.Format())
|
||||
}
|
||||
}
|
||||
@ -2141,7 +2141,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
values := map[string]*Message{}
|
||||
|
||||
for msg = msg; msg != nil; msg = msg.message {
|
||||
for k, v := range msg.sessions {
|
||||
for k, v := range msg.Sessions {
|
||||
if _, ok := values[k]; ok {
|
||||
continue
|
||||
}
|
||||
@ -2174,11 +2174,11 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
default:
|
||||
sub = nil
|
||||
}
|
||||
if msg.sessions == nil {
|
||||
msg.sessions = map[string]*Message{}
|
||||
if msg.Sessions == nil {
|
||||
msg.Sessions = map[string]*Message{}
|
||||
}
|
||||
if sub != nil {
|
||||
msg.sessions[arg[0]] = sub
|
||||
msg.Sessions[arg[0]] = sub
|
||||
}
|
||||
// }}}
|
||||
}},
|
||||
@ -2627,10 +2627,10 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
}
|
||||
|
||||
current := m.Target()
|
||||
aaa := m.Sess("aaa")
|
||||
aaa := m.Sess("aaa", false)
|
||||
void := index["void"]
|
||||
if aaa != nil && aaa.Cap("group") != aaa.Conf("rootname") {
|
||||
if current = index[aaa.Cap("group")]; current == nil {
|
||||
if aaa != nil && aaa.Cap("username") != aaa.Conf("rootname") {
|
||||
if current = index[aaa.Cap("username")]; current == nil {
|
||||
if void != nil {
|
||||
m.Echo("%s:caches\n", void.Name)
|
||||
for k, c := range void.Caches {
|
||||
|
@ -634,8 +634,8 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
// 共享列表
|
||||
share := m.Sess("share", m.Target())
|
||||
index := share.Target().Index
|
||||
if index != nil && index[aaa.Append("userrole")] != nil {
|
||||
for k, v := range index[aaa.Append("userrole")].Index {
|
||||
if index != nil && index[aaa.Append("username")] != nil {
|
||||
for k, v := range index[aaa.Append("username")].Index {
|
||||
for _, j := range v.Commands {
|
||||
for _, n := range j.Shares {
|
||||
for _, nn := range n {
|
||||
@ -794,7 +794,8 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
"/check": &ctx.Command{Name: "/check cache|config|command name args", Help: "权限检查, cache|config|command: 接口类型, name: 接口名称, args: 其它参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
w := m.Optionv("response").(http.ResponseWriter) //{{{
|
||||
if login := m.Spawn().Cmd("/login"); login.Has("redirect") {
|
||||
if msg := m.Spawn().Cmd("right", "check", login.Append("userrole"), arg); msg.Results(0) {
|
||||
aaa := m.Appendv("aaa").(*ctx.Message)
|
||||
if msg := m.Spawn().Cmd("right", "check", aaa.Cap("username"), arg); msg.Results(0) {
|
||||
m.Copy(login, "append").Echo(msg.Result(0))
|
||||
return
|
||||
}
|
||||
@ -813,6 +814,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
if m.Options("sessid") {
|
||||
if aaa := m.Find("aaa").Cmd("login", m.Option("sessid")); aaa.Results(0) {
|
||||
m.Append("redirect", m.Option("referer"))
|
||||
m.Appendv("aaa", aaa)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -821,6 +823,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
if aaa := m.Find("aaa").Cmd("login", m.Option("username"), m.Option("password")); aaa.Results(0) {
|
||||
http.SetCookie(w, &http.Cookie{Name: "sessid", Value: aaa.Result(0)})
|
||||
m.Append("redirect", m.Option("referer"))
|
||||
m.Appendv("aaa", aaa)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user