forked from x/icebergs
opt aaa
This commit is contained in:
parent
d4c197c737
commit
a2a14be186
@ -1,8 +1,6 @@
|
|||||||
package aaa
|
package aaa
|
||||||
|
|
||||||
import (
|
import ice "shylinux.com/x/icebergs"
|
||||||
ice "shylinux.com/x/icebergs"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RSA = "rsa"
|
RSA = "rsa"
|
||||||
|
@ -26,32 +26,28 @@ func init() {
|
|||||||
const (
|
const (
|
||||||
ADMIN = "admin"
|
ADMIN = "admin"
|
||||||
SERVICE = "service"
|
SERVICE = "service"
|
||||||
MAILBOX = "mailbox"
|
|
||||||
NL = "\r\n"
|
NL = "\r\n"
|
||||||
DF = ": "
|
DF = ": "
|
||||||
)
|
)
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
EMAIL: {Help: "邮件", Role: VOID, Actions: ice.MergeActions(ice.Actions{
|
EMAIL: {Help: "邮件", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create name*=admin service*='mail.shylinux.com:25' username*='shy@shylinux.com' password*"},
|
mdb.CREATE: {Name: "create name*=admin service*='mail.shylinux.com:25' username*='shy@shylinux.com' password*"},
|
||||||
MAILBOX: {Help: "邮箱", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if p := mdb.Config(m, MAILBOX); !m.Warn(p == "", ice.ErrNotValid, MAILBOX) {
|
|
||||||
m.EchoIFrame(p).ProcessInner()
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
SEND: {Name: "send from=admin to*='shy@shylinux.com' cc subject*=hi content*:textarea=hello", Help: "发送", Icon: "bi bi-send-plus", Hand: func(m *ice.Message, arg ...string) {
|
SEND: {Name: "send from=admin to*='shy@shylinux.com' cc subject*=hi content*:textarea=hello", Help: "发送", Icon: "bi bi-send-plus", Hand: func(m *ice.Message, arg ...string) {
|
||||||
msg := mdb.HashSelects(m.Spawn(), m.OptionDefault(FROM, ADMIN))
|
msg := mdb.HashSelects(m.Spawn(), m.OptionDefault(FROM, ADMIN))
|
||||||
if m.Warn(msg.Append(SERVICE) == "", ice.ErrNotValid, SERVICE) {
|
if m.WarnNotFound(msg.Append(SERVICE) == "", m.Option(FROM)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Toast(ice.PROCESS, "", "-1")
|
m.Toast(ice.PROCESS, "", "-1")
|
||||||
defer m.Toast(ice.SUCCESS)
|
|
||||||
content := []byte(kit.JoinKV(DF, NL, kit.Simple(FROM, msg.Append(USERNAME), m.OptionSimple(TO, CC, SUBJECT), DATE, time.Now().Format(time.RFC1123Z), "Content-Type", "text/html; charset=UTF-8")...) + NL + NL + m.Option(CONTENT))
|
content := []byte(kit.JoinKV(DF, NL, kit.Simple(FROM, msg.Append(USERNAME), m.OptionSimple(TO, CC, SUBJECT), DATE, time.Now().Format(time.RFC1123Z), "Content-Type", "text/html; charset=UTF-8")...) + NL + NL + m.Option(CONTENT))
|
||||||
auth := smtp.PlainAuth("", msg.Append(USERNAME), msg.Append(PASSWORD), kit.Split(msg.Append(SERVICE), ice.DF)[0])
|
auth := smtp.PlainAuth("", msg.Append(USERNAME), msg.Append(PASSWORD), kit.Split(msg.Append(SERVICE), ice.DF)[0])
|
||||||
m.Logs(EMAIL, SEND, string(content)).Warn(smtp.SendMail(msg.Append(SERVICE), auth, msg.Append(USERNAME), kit.Split(m.Option(TO)), content))
|
m.Logs(EMAIL, SEND, string(content))
|
||||||
|
if !m.Warn(smtp.SendMail(msg.Append(SERVICE), auth, msg.Append(USERNAME), kit.Split(m.Option(TO)), content)) {
|
||||||
|
m.Toast(ice.SUCCESS)
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
}, mdb.DevDataAction("name,service,username,password"), mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username", ice.ACTION, SEND)), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.DevDataAction("name,service,username,password"), mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username", ice.ACTION, SEND)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if mdb.HashSelect(m, arg...); len(arg) == 0 && m.Length() == 0 {
|
if mdb.HashSelect(m, arg...); len(arg) == 0 && m.Length() == 0 {
|
||||||
m.EchoInfoButton(ice.Info.Template(m, "email.html"), mdb.CREATE, mdb.DEV_REQUEST)
|
m.EchoInfoButton(m.Trans("please add admin email", "请配置管理员邮箱"), mdb.CREATE, mdb.DEV_REQUEST)
|
||||||
} else if len(arg) == 0 {
|
} else if len(arg) == 0 {
|
||||||
m.Action(mdb.CREATE, mdb.DEV_REQUEST)
|
m.Action(mdb.CREATE, mdb.DEV_REQUEST)
|
||||||
}
|
}
|
||||||
@ -61,7 +57,7 @@ func init() {
|
|||||||
func SendEmail(m *ice.Message, from, to, cc string, arg ...string) {
|
func SendEmail(m *ice.Message, from, to, cc string, arg ...string) {
|
||||||
m.Option(ice.MSG_USERHOST, strings.Split(m.Option(ice.MSG_USERHOST), "://")[1])
|
m.Option(ice.MSG_USERHOST, strings.Split(m.Option(ice.MSG_USERHOST), "://")[1])
|
||||||
m.Cmdy(EMAIL, SEND, kit.Select(mdb.Config(m, EMAIL), from), kit.Select(m.Option(EMAIL), to), cc,
|
m.Cmdy(EMAIL, SEND, kit.Select(mdb.Config(m, EMAIL), from), kit.Select(m.Option(EMAIL), to), cc,
|
||||||
strings.TrimSpace(kit.Select(ice.Render(m, ice.RENDER_TEMPLATE, "subject.html"), arg, 0)),
|
strings.TrimSpace(kit.Select(ice.Render(m, ice.RENDER_TEMPLATE, SUBJECT_HTML), arg, 0)),
|
||||||
kit.Select(ice.Render(m, ice.RENDER_TEMPLATE, "content.html"), arg, 1),
|
kit.Select(ice.Render(m, ice.RENDER_TEMPLATE, CONTENT_HTML), arg, 1),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,13 @@ const (
|
|||||||
INVITER = "inviter"
|
INVITER = "inviter"
|
||||||
INVITE = "invite"
|
INVITE = "invite"
|
||||||
ACCEPT = "accept"
|
ACCEPT = "accept"
|
||||||
|
SUBJECT_HTML = "subject.html"
|
||||||
|
CONTENT_HTML = "content.html"
|
||||||
)
|
)
|
||||||
const APPLY = "apply"
|
const APPLY = "apply"
|
||||||
const OFFER = "offer"
|
const OFFER = "offer"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
const (
|
|
||||||
SUBJECT_HTML = "subject.html"
|
|
||||||
CONTENT_HTML = "content.html"
|
|
||||||
)
|
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
OFFER: {Help: "邀请", Role: VOID, Meta: kit.Dict(
|
OFFER: {Help: "邀请", Role: VOID, Meta: kit.Dict(
|
||||||
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict("from", "发自", "inviter", "邀请人")),
|
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict("from", "发自", "inviter", "邀请人")),
|
||||||
@ -32,25 +30,25 @@ func init() {
|
|||||||
m.Cmd("count", mdb.CREATE, OFFER, m.Option(FROM), kit.Dict(ice.LOG_DISABLE, ice.TRUE))
|
m.Cmd("count", mdb.CREATE, OFFER, m.Option(FROM), kit.Dict(ice.LOG_DISABLE, ice.TRUE))
|
||||||
}},
|
}},
|
||||||
ACCEPT: {Help: "接受", Role: VOID, Hand: func(m *ice.Message, arg ...string) {
|
ACCEPT: {Help: "接受", Role: VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Warn(m.Option(mdb.HASH) == "", ice.ErrNotValid, mdb.HASH) {
|
if m.WarnNotValid(m.Option(mdb.HASH) == "", mdb.HASH) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := mdb.HashSelect(m.Spawn(), m.Option(mdb.HASH))
|
msg := mdb.HashSelect(m.Spawn(), m.Option(mdb.HASH))
|
||||||
if ls := kit.Split(msg.Append(EMAIL), mdb.AT); !m.Warn(msg.Length() == 0 || len(ls) < 2, ice.ErrNotValid, m.Option(mdb.HASH)) {
|
if ls := kit.Split(msg.Append(EMAIL), mdb.AT); !m.WarnNotFound(msg.Length() == 0 || len(ls) < 2, m.Option(mdb.HASH)) {
|
||||||
ice.Info.AdminCmd(m.Spawn(), USER, mdb.CREATE, USERNICK, ls[0], USERNAME, msg.Append(EMAIL), USERZONE, ls[1])
|
ice.Info.AdminCmd(m.Spawn(), USER, mdb.CREATE, USERNICK, ls[0], USERNAME, msg.Append(EMAIL), USERZONE, ls[1])
|
||||||
m.ProcessLocation(m.MergePod("", ice.MSG_SESSID, SessValid(m.Options(ice.MSG_USERNAME, msg.Append(EMAIL)))))
|
m.ProcessLocation(m.MergePod("", ice.MSG_SESSID, SessValid(m.Options(ice.MSG_USERNAME, msg.Append(EMAIL)))))
|
||||||
mdb.HashModify(m, m.OptionSimple(mdb.HASH), mdb.STATUS, ACCEPT)
|
mdb.HashModify(m, m.OptionSimple(mdb.HASH), mdb.STATUS, ACCEPT)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, mdb.ImportantHashAction(EMAIL, ADMIN, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,status,inviter,email,title,content")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.ImportantHashAction(EMAIL, ADMIN, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,status,inviter,email,title,content")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if !m.Warn(len(arg) == 0 && m.Option(ice.MSG_USERROLE) == VOID, ice.ErrNotRight) {
|
if !m.WarnNotRight(len(arg) == 0 && m.Option(ice.MSG_USERROLE) == VOID) {
|
||||||
kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() {
|
kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() {
|
||||||
if m.Option(ice.MSG_USERNAME) != "" {
|
if m.Option(ice.MSG_USERNAME) == "" {
|
||||||
m.ProcessLocation(m.MergePod(""))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Option(ice.MSG_USERHOST, strings.Split(m.Option(ice.MSG_USERHOST), "://")[1])
|
m.Option(ice.MSG_USERHOST, strings.Split(m.Option(ice.MSG_USERHOST), "://")[1])
|
||||||
m.SetAppend().EchoInfoButton(ice.Info.Template(m, SUBJECT_HTML), ACCEPT)
|
m.SetAppend().EchoInfoButton(ice.Info.Template(m, SUBJECT_HTML), ACCEPT)
|
||||||
|
} else {
|
||||||
|
m.ProcessLocation(m.MergePod(""))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -31,16 +31,16 @@ func (s apply) Apply(m *ice.Message, arg ...string) {
|
|||||||
if k := _cookie_key(m); m.Option(k) == "" || s.List(m, m.Option(k)).Length() == 0 && m.Result() == "" {
|
if k := _cookie_key(m); m.Option(k) == "" || s.List(m, m.Option(k)).Length() == 0 && m.Result() == "" {
|
||||||
m.DisplayForm(m, "email*", aaa.USERNICK, s.Apply)
|
m.DisplayForm(m, "email*", aaa.USERNICK, s.Apply)
|
||||||
}
|
}
|
||||||
} else if !m.Warn(m.Options(arg).Cmd(aaa.USER, m.Option(aaa.EMAIL)).Length() > 0, ice.ErrAlreadyExists, aaa.USER, m.Option(aaa.EMAIL)) {
|
} else if !m.WarnAlreadyExists(m.Options(arg).Cmd(aaa.USER, m.Option(aaa.EMAIL)).Length() > 0, m.Option(aaa.EMAIL)) {
|
||||||
m.ProcessCookie(_cookie_key(m), s.Hash.Create(m, kit.Simple(append(arg, mdb.STATUS, kit.FuncName(s.Apply), aaa.USERNAME, m.Option(aaa.EMAIL)), web.ParseUA(m.Message), cli.DAEMON, m.Option(ice.MSG_DAEMON))...))
|
m.ProcessCookie(_cookie_key(m), s.Hash.Create(m, kit.Simple(append(arg, mdb.STATUS, kit.FuncName(s.Apply), aaa.USERNAME, m.Option(aaa.EMAIL)), web.ParseUA(m.Message), cli.DAEMON, m.Option(ice.MSG_DAEMON))...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s apply) Agree(m *ice.Message, arg ...string) {
|
func (s apply) Agree(m *ice.Message, arg ...string) {
|
||||||
if m.Warn(m.Option(mdb.HASH) == "", ice.ErrNotValid, mdb.PARAMS, mdb.HASH) {
|
if m.WarnNotValid(m.Option(mdb.HASH) == "", mdb.HASH) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := s.Hash.List(m.Spawn(), m.Option(mdb.HASH))
|
msg := s.Hash.List(m.Spawn(), m.Option(mdb.HASH))
|
||||||
if m.Warn(msg.Length() == 0, ice.ErrNotFound, m.PrefixKey(), m.Option(mdb.HASH)) {
|
if m.WarnNotFound(msg.Length() == 0, m.Option(mdb.HASH)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.Hash.Modify(m, kit.Simple(m.OptionSimple(mdb.HASH, aaa.USERROLE), mdb.STATUS, s.Agree)...)
|
s.Hash.Modify(m, kit.Simple(m.OptionSimple(mdb.HASH, aaa.USERROLE), mdb.STATUS, s.Agree)...)
|
||||||
@ -52,12 +52,12 @@ func (s apply) Login(m *ice.Message, arg ...string) {
|
|||||||
if m.IsGetMethod() {
|
if m.IsGetMethod() {
|
||||||
m.DisplayForm("email*", s.Login)
|
m.DisplayForm("email*", s.Login)
|
||||||
} else if m.Options(arg).Option(aaa.EMAIL) == "" {
|
} else if m.Options(arg).Option(aaa.EMAIL) == "" {
|
||||||
if m.Warn(m.OptionDefault(mdb.HASH, m.Option(_cookie_key(m))) == "", ice.ErrNotValid, mdb.PARAMS, mdb.HASH) {
|
if m.WarnNotValid(m.OptionDefault(mdb.HASH, m.Option(_cookie_key(m))) == "", mdb.HASH) {
|
||||||
m.ProcessCookie(_cookie_key(m), "")
|
m.ProcessCookie(_cookie_key(m), "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := s.Hash.List(m.Spawn(), m.Option(mdb.HASH))
|
msg := s.Hash.List(m.Spawn(), m.Option(mdb.HASH))
|
||||||
if m.Warn(msg.Length() == 0, ice.ErrNotFound, m.PrefixKey(), m.Option(mdb.HASH)) {
|
if m.WarnNotFound(msg.Length() == 0, m.Option(mdb.HASH)) {
|
||||||
m.ProcessCookie(_cookie_key(m), "")
|
m.ProcessCookie(_cookie_key(m), "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -65,13 +65,13 @@ func (s apply) Login(m *ice.Message, arg ...string) {
|
|||||||
web.RenderCookie(m.Message, m.Cmdx(aaa.SESS, mdb.CREATE, msg.Append(aaa.USERNAME)))
|
web.RenderCookie(m.Message, m.Cmdx(aaa.SESS, mdb.CREATE, msg.Append(aaa.USERNAME)))
|
||||||
m.ProcessLocation(nfs.PS)
|
m.ProcessLocation(nfs.PS)
|
||||||
} else {
|
} else {
|
||||||
if m.Warn(m.Cmd(aaa.USER, m.Option(aaa.EMAIL)).Length() == 0, ice.ErrNotFound, aaa.USER, m.Option(aaa.EMAIL)) {
|
if m.WarnNotFound(m.Cmd(aaa.USER, m.Option(aaa.EMAIL)).Length() == 0, m.Option(aaa.EMAIL)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Options(ice.MSG_USERNAME, m.Option(aaa.EMAIL))
|
m.Options(ice.MSG_USERNAME, m.Option(aaa.EMAIL))
|
||||||
space := kit.Keys(kit.Slice(kit.Split(m.Option(ice.MSG_DAEMON), nfs.PT), 0, -1))
|
space := kit.Keys(kit.Slice(kit.Split(m.Option(ice.MSG_DAEMON), nfs.PT), 0, -1))
|
||||||
share := m.Cmd(web.SHARE, mdb.CREATE, mdb.TYPE, web.FIELD, mdb.NAME, web.CHAT_GRANT, mdb.TEXT, space).Append(mdb.LINK)
|
share := m.Cmd(web.SHARE, mdb.CREATE, mdb.TYPE, web.FIELD, mdb.NAME, web.CHAT_GRANT, mdb.TEXT, space).Append(mdb.LINK)
|
||||||
m.SendEmail(m.Options(web.LINK, share), "", "", "")
|
m.Options(web.LINK, share).SendEmail("", "", "")
|
||||||
m.ProcessHold(m.Trans("please auth login in mailbox", "请注意查收邮件"))
|
m.ProcessHold(m.Trans("please auth login in mailbox", "请注意查收邮件"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
if arg[0] == mdb.KEY {
|
||||||
case mdb.KEY:
|
|
||||||
mdb.HashInputs(m, ice.INDEX).CutTo(ice.INDEX, arg[0])
|
mdb.HashInputs(m, ice.INDEX).CutTo(ice.INDEX, arg[0])
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
@ -164,6 +163,4 @@ func Right(m *ice.Message, key ...ice.Any) bool {
|
|||||||
return !ice.Info.Important || m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK,
|
return !ice.Info.Important || m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK,
|
||||||
ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-1))
|
ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-1))
|
||||||
}
|
}
|
||||||
func IsTechOrRoot(m *ice.Message) bool {
|
func IsTechOrRoot(m *ice.Message) bool { return kit.IsIn(m.Option(ice.MSG_USERROLE), TECH, ROOT) }
|
||||||
return kit.IsIn(m.Option(ice.MSG_USERROLE), TECH, ROOT)
|
|
||||||
}
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package aaa
|
package aaa
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/web/html"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
"shylinux.com/x/toolkits/logs"
|
"shylinux.com/x/toolkits/logs"
|
||||||
)
|
)
|
||||||
@ -18,7 +15,7 @@ func _sess_create(m *ice.Message, username string, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _sess_check(m *ice.Message, sessid string) {
|
func _sess_check(m *ice.Message, sessid string) {
|
||||||
if val := mdb.HashSelectDetails(m, sessid, func(value ice.Map) bool { return !m.WarnTimeNotValid(value[mdb.TIME], sessid) }); len(val) > 0 {
|
if val := mdb.HashSelectDetails(m, sessid, func(value ice.Map) bool { return !m.WarnNotValidTime(value[mdb.TIME], sessid) }); len(val) > 0 {
|
||||||
SessAuth(m, val)
|
SessAuth(m, val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,20 +56,12 @@ func SessValid(m *ice.Message) string {
|
|||||||
return m.Option(ice.MSG_SESSID)
|
return m.Option(ice.MSG_SESSID)
|
||||||
}
|
}
|
||||||
func SessAuth(m *ice.Message, value ice.Any, arg ...string) *ice.Message {
|
func SessAuth(m *ice.Message, value ice.Any, arg ...string) *ice.Message {
|
||||||
language := kit.Select(m.Option(ice.MSG_LANGUAGE), kit.Format(kit.Value(value, LANGUAGE)))
|
|
||||||
kit.If(language == "", func() {
|
|
||||||
kit.If(kit.Format(kit.Value(value, USERNAME)), func(p string) { language = m.Cmdv(USER, p, LANGUAGE) })
|
|
||||||
})
|
|
||||||
kit.If(language == "", func() { language = kit.Select("", "zh-cn", strings.Contains(m.Option(ice.MSG_USERUA), "zh_CN")) })
|
|
||||||
kit.If(language == "" && m.R != nil, func() { language = kit.Select("", kit.Split(m.R.Header.Get(html.AcceptLanguage), ",;"), 0) })
|
|
||||||
kit.If(language == "", func() { language = ice.Info.Lang })
|
|
||||||
language = strings.ReplaceAll(strings.ToLower(kit.Select("", kit.Split(language, " ."), 0)), "_", "-")
|
|
||||||
return m.Auth(
|
return m.Auth(
|
||||||
USERROLE, m.Option(ice.MSG_USERROLE, kit.Format(kit.Value(value, USERROLE))),
|
USERROLE, m.Option(ice.MSG_USERROLE, kit.Format(kit.Value(value, USERROLE))),
|
||||||
USERNAME, m.Option(ice.MSG_USERNAME, kit.Format(kit.Value(value, USERNAME))),
|
USERNAME, m.Option(ice.MSG_USERNAME, kit.Format(kit.Value(value, USERNAME))),
|
||||||
USERNICK, m.Option(ice.MSG_USERNICK, kit.Format(kit.Value(value, USERNICK))),
|
USERNICK, m.Option(ice.MSG_USERNICK, kit.Format(kit.Value(value, USERNICK))),
|
||||||
LANGUAGE, m.Option(ice.MSG_LANGUAGE, language), arg,
|
LANGUAGE, m.OptionDefault(ice.MSG_LANGUAGE, kit.Format(kit.Value(value, LANGUAGE))),
|
||||||
logs.FileLineMeta(kit.Select(logs.FileLine(-1), m.Option("aaa.checker"))),
|
arg, logs.FileLineMeta(kit.Select(logs.FileLine(-1), m.Option("aaa.checker"))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
func SessLogout(m *ice.Message, arg ...string) {
|
func SessLogout(m *ice.Message, arg ...string) {
|
||||||
|
@ -60,9 +60,7 @@ func init() {
|
|||||||
m.Echo(m.Append(mdb.VALUE))
|
m.Echo(m.Append(mdb.VALUE))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if len(arg) == 0 {
|
kit.If(len(arg) == 0, func() { m.PushAction(mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES) })
|
||||||
m.PushAction(mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES)
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -73,12 +73,12 @@ func UserNick(m *ice.Message, username ice.Any) (nick string) {
|
|||||||
func UserRole(m *ice.Message, username ice.Any) (role string) {
|
func UserRole(m *ice.Message, username ice.Any) (role string) {
|
||||||
if username == "" {
|
if username == "" {
|
||||||
return VOID
|
return VOID
|
||||||
}
|
} else if role = VOID; username == ice.Info.Username {
|
||||||
if role = VOID; username == ice.Info.Username {
|
|
||||||
return ROOT
|
return ROOT
|
||||||
}
|
} else {
|
||||||
return UserInfo(m, username, USERROLE, ice.MSG_USERROLE)
|
return UserInfo(m, username, USERROLE, ice.MSG_USERROLE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
func UserZone(m *ice.Message, username ice.Any) (zone string) {
|
func UserZone(m *ice.Message, username ice.Any) (zone string) {
|
||||||
return UserInfo(m, username, USERZONE, ice.MSG_USERZONE)
|
return UserInfo(m, username, USERZONE, ice.MSG_USERZONE)
|
||||||
}
|
}
|
||||||
|
@ -124,11 +124,12 @@ func init() {
|
|||||||
if ice.Info.NodeType == web.WORKER {
|
if ice.Info.NodeType == web.WORKER {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
kit.If(m.Option(ice.MSG_USERPOD), func(p string) {
|
kit.If(m.Option(ice.MSG_USERPOD), func(p string) { m.Option(ice.MSG_NODETYPE, m.Cmdx(web.SPACE, p, cli.RUNTIME, ice.MSG_NODETYPE)) })
|
||||||
m.Option(ice.MSG_NODETYPE, m.Cmdx(web.SPACE, p, cli.RUNTIME, ice.MSG_NODETYPE))
|
m.Option(aaa.LANGUAGE, strings.ReplaceAll(strings.ToLower(kit.Select("", kit.Split(kit.GetValid(
|
||||||
})
|
func() string { return kit.Select("", "zh-cn", strings.Contains(m.Option(ice.MSG_USERUA), "zh_CN")) },
|
||||||
m.OptionDefault(ice.MSG_LANGUAGE, strings.ToLower(kit.Select("", kit.Split(m.R.Header.Get(html.AcceptLanguage), ",;"), 0)))
|
func() string { return kit.Select("", kit.Split(m.R.Header.Get(html.AcceptLanguage), ",;"), 0) },
|
||||||
m.OptionDefault(aaa.LANGUAGE, m.Option(ice.MSG_LANGUAGE))
|
func() string { return ice.Info.Lang },
|
||||||
|
), " ."), 0)), "_", "-"))
|
||||||
m.Option("language.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.LANGUAGE)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
m.Option("language.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.LANGUAGE)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
||||||
m.Option("theme.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.THEME)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
m.Option("theme.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.THEME)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
||||||
m.Option(nfs.REPOS, m.Cmdv(web.SPIDE, nfs.REPOS, web.CLIENT_URL))
|
m.Option(nfs.REPOS, m.Cmdv(web.SPIDE, nfs.REPOS, web.CLIENT_URL))
|
||||||
@ -138,7 +139,7 @@ func init() {
|
|||||||
mdb.HashSelect(m, arg...).Sort(mdb.ORDER, ice.INT)
|
mdb.HashSelect(m, arg...).Sort(mdb.ORDER, ice.INT)
|
||||||
m.Table(func(value ice.Maps) { m.Push(mdb.STATUS, kit.Select(mdb.ENABLE, mdb.DISABLE, value[mdb.ORDER] == "")) })
|
m.Table(func(value ice.Maps) { m.Push(mdb.STATUS, kit.Select(mdb.ENABLE, mdb.DISABLE, value[mdb.ORDER] == "")) })
|
||||||
kit.If(m.Length() == 0, func() {
|
kit.If(m.Length() == 0, func() {
|
||||||
m.Push(mdb.TIME, m.Time()).Push(mdb.NAME, "qrcode").Push(mdb.HELP, "扫码登录").Push(mdb.ICONS, nfs.USR_ICONS_VOLCANOS).Push(mdb.TYPE, cli.QRCODE).Push(web.LINK, "").Push(mdb.ORDER, "10")
|
m.Push(mdb.TIME, m.Time()).Push(mdb.NAME, cli.QRCODE).Push(mdb.HELP, "扫码登录").Push(mdb.ICONS, nfs.USR_ICONS_VOLCANOS).Push(mdb.TYPE, cli.QRCODE).Push(web.LINK, "").Push(mdb.ORDER, "10")
|
||||||
})
|
})
|
||||||
kit.If(GetSSO(m), func(p string) {
|
kit.If(GetSSO(m), func(p string) {
|
||||||
m.Push(mdb.TIME, m.Time()).Push(mdb.NAME, web.SERVE).Push(mdb.ICONS, nfs.USR_ICONS_ICEBERGS).Push(mdb.TYPE, "oauth").Push(web.LINK, p)
|
m.Push(mdb.TIME, m.Time()).Push(mdb.NAME, web.SERVE).Push(mdb.ICONS, nfs.USR_ICONS_ICEBERGS).Push(mdb.TYPE, "oauth").Push(web.LINK, p)
|
||||||
@ -149,7 +150,7 @@ func init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
||||||
kit.For([]string{aaa.USERNICK, aaa.EMAIL, aaa.LANGUAGE}, func(k string) { m.OptionDefault(k, msg.Append(k)) })
|
kit.For([]string{aaa.EMAIL, aaa.LANGUAGE, aaa.USERNICK}, func(k string) { kit.If(msg.Append(k), func(v string) { m.Option(k, v) }) })
|
||||||
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))) })
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -15,7 +15,6 @@ fieldset.macos.desktop>div.output>fieldset.macos.dock { border:var(--box-border)
|
|||||||
fieldset.macos.desktop>div.output>fieldset.macos.searchs { position:absolute; z-index:11; }
|
fieldset.macos.desktop>div.output>fieldset.macos.searchs { position:absolute; z-index:11; }
|
||||||
fieldset.macos.desktop>div.output>fieldset.macos.notifications { height:calc(100% - 125px); width:320px; overflow:auto; position:absolute; top:var(--desktop-menu-height); left:calc(100% - 320px); z-index:11; }
|
fieldset.macos.desktop>div.output>fieldset.macos.notifications { height:calc(100% - 125px); width:320px; overflow:auto; position:absolute; top:var(--desktop-menu-height); left:calc(100% - 320px); z-index:11; }
|
||||||
fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.action>div.item { padding:0; }
|
fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.action>div.item { padding:0; }
|
||||||
// fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.action>div.item.refresh>span { font-size:var(--action-height); margin-top:-5px; }
|
|
||||||
fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item { clear:both; display:flex; padding:var(--input-padding)}
|
fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item { clear:both; display:flex; padding:var(--input-padding)}
|
||||||
fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item:not(:last-child) { border-bottom:var(--box-border); }
|
fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item:not(:last-child) { border-bottom:var(--box-border); }
|
||||||
fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item.read { color:var(--disable-fg-color); }
|
fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item.read { color:var(--disable-fg-color); }
|
||||||
@ -32,7 +31,7 @@ fieldset.macos.desktop>div.output>div.desktop>div.item img { object-fit:contain;
|
|||||||
fieldset.macos.desktop>div.output>div.desktop>div.item>div.name { font-size:var(--code-font-size); width:var(--desktop-icon-size); overflow:hidden; }
|
fieldset.macos.desktop>div.output>div.desktop>div.item>div.name { font-size:var(--code-font-size); width:var(--desktop-icon-size); overflow:hidden; }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset { border-radius:var(--plugin-radius); position:absolute; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset { border-radius:var(--plugin-radius); position:absolute; }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset.select { z-index:1; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset.select { z-index:1; }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.item.button { border-radius:var(--plugin-radius); box-shadow:var(--box-shadow); padding:8px; height:23px; width:23px; scale:0.7; position:absolute; top:14px; right:var(--plugin-padding); cursor:pointer; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.item.button { border-radius:var(--plugin-radius); box-shadow:var(--box-shadow); padding:8px; height:23px; width:23px; scale:0.7; position:absolute; top:10px; right:var(--plugin-padding); cursor:pointer; }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.item.button:not(:hover)>span { display:none; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.item.button:not(:hover)>span { display:none; }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>legend { padding:0 var(--input-padding); margin:var(--button-margin); box-shadow:none; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>legend { padding:0 var(--input-padding); margin:var(--button-margin); box-shadow:none; }
|
||||||
body.mobile fieldset.macos.desktop>div.output>div.desktop>fieldset>legend { float:none; }
|
body.mobile fieldset.macos.desktop>div.output>div.desktop>fieldset>legend { float:none; }
|
||||||
@ -42,7 +41,6 @@ fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>*:not(.textar
|
|||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.icon { margin:var(--button-margin) 0; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.icon { margin:var(--button-margin) 0; }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.list.icons { margin:var(--button-margin) 0; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.list.icons { margin:var(--button-margin) 0; }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.back.icons { margin:var(--button-margin) 0; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.back.icons { margin:var(--button-margin) 0; }
|
||||||
/* fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item:last-child { margin-right:100px; } */
|
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.item:last-child { margin-right:100px; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.item:last-child { margin-right:100px; }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>* { margin:var(--button-margin) var(--input-margin); }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>* { margin:var(--button-margin) var(--input-margin); }
|
||||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.tabs { display:none; }
|
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.tabs { display:none; }
|
||||||
|
16
logs.go
16
logs.go
@ -131,8 +131,20 @@ func (m *Message) Warn(err Any, arg ...Any) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (m *Message) WarnTimeNotValid(time Any, arg ...Any) bool {
|
func (m *Message) WarnNotValidTime(time Any, arg ...Any) bool {
|
||||||
return m.Warn(kit.Format(time) < m.Time(), ErrNotValid, kit.Simple(arg), time, m.Time(), logs.FileLineMeta(2))
|
return m.Warn(kit.Format(time) < m.Time(), ErrNotValid, kit.Simple(arg...), time, m.Time(), logs.FileLineMeta(2))
|
||||||
|
}
|
||||||
|
func (m *Message) WarnNotValid(err Any, arg ...Any) bool {
|
||||||
|
return m.Warn(err, ErrNotValid, kit.Simple(arg...), logs.FileLineMeta(2))
|
||||||
|
}
|
||||||
|
func (m *Message) WarnNotFound(err Any, arg ...Any) bool {
|
||||||
|
return m.Warn(err, ErrNotFound, kit.Simple(arg...), logs.FileLineMeta(2))
|
||||||
|
}
|
||||||
|
func (m *Message) WarnNotRight(err Any, arg ...Any) bool {
|
||||||
|
return m.Warn(err, ErrNotRight, kit.Simple(arg...), logs.FileLineMeta(2))
|
||||||
|
}
|
||||||
|
func (m *Message) WarnAlreadyExists(err Any, arg ...Any) bool {
|
||||||
|
return m.Warn(err, ErrAlreadyExists, kit.Simple(arg...), logs.FileLineMeta(2))
|
||||||
}
|
}
|
||||||
func (m *Message) ErrorNotImplement(arg ...Any) *Message {
|
func (m *Message) ErrorNotImplement(arg ...Any) *Message {
|
||||||
m.Error(true, append(kit.List(ErrNotImplement), arg...)...)
|
m.Error(true, append(kit.List(ErrNotImplement), arg...)...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user