diff --git a/core/chat/center/password.go b/core/chat/center/password.go new file mode 100644 index 00000000..5ea58116 --- /dev/null +++ b/core/chat/center/password.go @@ -0,0 +1,33 @@ +package center + +import ( + "shylinux.com/x/ice" + "shylinux.com/x/icebergs/base/aaa" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/web" +) + +type password struct { + change string `name:"change" help:"修改登录"` + login string `name:"login username* password*" help:"登录" role:"void"` + list string `name:"list refresh" help:"密码登录" role:"void"` +} + +func (s password) Change(m *ice.Message, arg ...string) { + m.Cmd(aaa.USER, mdb.MODIFY, aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.PASSWORD, arg[1]) +} +func (s password) Login(m *ice.Message, arg ...string) { + if m.WarnNotValid(m.Option(aaa.PASSWORD) != m.Cmd(aaa.USER, m.Option(aaa.USERNAME)).Append(aaa.PASSWORD), aaa.PASSWORD) { + return + } + web.RenderCookie(m.Message, aaa.SessCreate(m.Message, m.Option(aaa.USERNAME))) +} +func (s password) List(m *ice.Message, arg ...string) { + if m.Option(ice.MSG_USERNAME) == "" { + m.DisplayForm("username*", "password*", s.Login) + } else { + m.DisplayForm("password*", s.Change) + } +} + +func init() { ice.Cmd("web.chat.password", password{}) } diff --git a/core/chat/password.go b/core/chat/password.go index 2aeef28a..9968e410 100644 --- a/core/chat/password.go +++ b/core/chat/password.go @@ -1,11 +1,3 @@ package chat -import ice "shylinux.com/x/icebergs" - -func init() { - Index.MergeCommands(ice.Commands{ - "password": {Name: "password", Hand: func(m *ice.Message, arg ...string) { - m.Echo("hello world") - }}, - }) -} +func init() {}