diff --git a/app/controllers/AuthController.go b/app/controllers/AuthController.go index c12dc08..3814668 100644 --- a/app/controllers/AuthController.go +++ b/app/controllers/AuthController.go @@ -20,7 +20,7 @@ func (c Auth) Login(email, from string) revel.Result { c.RenderArgs["subTitle"] = c.Message("login") c.RenderArgs["email"] = email c.RenderArgs["from"] = from - c.RenderArgs["openRegister"] = openRegister + c.RenderArgs["openRegister"] = configService.IsOpenRegister() sessionId := c.Session.Id() if sessionService.LoginTimesIsOver(sessionId) { @@ -92,7 +92,7 @@ func (c Auth) Demo() revel.Result { //-------- // 注册 func (c Auth) Register(from string) revel.Result { - if !openRegister { + if !configService.IsOpenRegister() { return c.Redirect("/index") } c.SetLocale() @@ -103,7 +103,7 @@ func (c Auth) Register(from string) revel.Result { return c.RenderTemplate("home/register.html") } func (c Auth) DoRegister(email, pwd string) revel.Result { - if !openRegister { + if !configService.IsOpenRegister() { return c.Redirect("/index") } diff --git a/app/controllers/IndexController.go b/app/controllers/IndexController.go index c357f66..b6a86a6 100644 --- a/app/controllers/IndexController.go +++ b/app/controllers/IndexController.go @@ -16,7 +16,7 @@ type Index struct { func (c Index) Index() revel.Result { c.SetUserInfo() c.RenderArgs["title"] = "leanote" - c.RenderArgs["openRegister"] = openRegister + c.RenderArgs["openRegister"] = configService.GlobalStringConfigs["openRegister"] lang := c.SetLocale() return c.RenderTemplate("home/index_" + lang + ".html"); diff --git a/app/controllers/NoteController.go b/app/controllers/NoteController.go index aca4420..a321e42 100644 --- a/app/controllers/NoteController.go +++ b/app/controllers/NoteController.go @@ -33,7 +33,7 @@ func (c Note) Index() revel.Result { return c.Redirect("/login") } - c.RenderArgs["openRegister"] = openRegister + c.RenderArgs["openRegister"] = configService.IsOpenRegister() // 已登录了, 那么得到所有信息 notebooks := notebookService.GetNotebooks(userId) diff --git a/app/controllers/admin/AdminSettingController.go b/app/controllers/admin/AdminSettingController.go index 41d92ac..e46c58d 100644 --- a/app/controllers/admin/AdminSettingController.go +++ b/app/controllers/admin/AdminSettingController.go @@ -104,6 +104,12 @@ func (c AdminSetting) DoSubDomain(noteSubDomain, blogSubDomain, leaSubDomain, bl return c.RenderJson(re) } +func (c AdminSetting) OpenRegister(openRegister string) revel.Result { + re := info.NewRe() + re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "openRegister", openRegister) + return c.RenderJson(re) +} + func (c AdminSetting) Mongodb(mongodumpPath, mongorestorePath string) revel.Result { re := info.NewRe() re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "mongodumpPath", mongodumpPath) diff --git a/app/controllers/init.go b/app/controllers/init.go index cc257ed..19f00a2 100644 --- a/app/controllers/init.go +++ b/app/controllers/init.go @@ -30,9 +30,8 @@ var sessionService *service.SessionService var pageSize = 1000 var defaultSortField = "UpdatedTime" -var leanoteUserId = "52d26b4e99c37b609a000001" +var leanoteUserId = "admin" // 不能更改 var siteUrl = "http://leanote.com" -var openRegister = true // 拦截器 // 不需要拦截的url @@ -142,8 +141,6 @@ func init() { revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &NoteContentHistory{}) revel.OnAppStart(func() { - leanoteUserId, _ = revel.Config.String("adminUsername") siteUrl, _ = revel.Config.String("site.url") - openRegister, _ = revel.Config.Bool("register.open") }) } \ No newline at end of file diff --git a/app/service/ConfigService.go b/app/service/ConfigService.go index eed84bd..dfe7401 100644 --- a/app/service/ConfigService.go +++ b/app/service/ConfigService.go @@ -162,6 +162,10 @@ func (this *ConfigService) GetGlobalArrMapConfig(key string) []map[string]string } return m } + +func (this *ConfigService) IsOpenRegister() bool { + return this.GetGlobalStringConfig("openRegister") != "" +} //------- // 修改共享笔记的配置 func (this *ConfigService) UpdateShareNoteConfig(registerSharedUserId string, diff --git a/app/service/UserService.go b/app/service/UserService.go index 760ef65..fd9a81d 100644 --- a/app/service/UserService.go +++ b/app/service/UserService.go @@ -26,7 +26,7 @@ func (this *UserService) AddUser(user info.User) bool { go func() { emailService.RegisterSendActiveEmail(user, user.Email) // 发送给我 life@leanote.com - emailService.SendEmail("life@leanote.com", "新增用户", "{header}用户名" + user.Email + "{footer}"); + // emailService.SendEmail("life@leanote.com", "新增用户", "{header}用户名" + user.Email + "{footer}"); }(); } diff --git a/app/views/Admin/Setting/openRegister.html b/app/views/Admin/Setting/openRegister.html new file mode 100644 index 0000000..b5345ed --- /dev/null +++ b/app/views/Admin/Setting/openRegister.html @@ -0,0 +1,48 @@ +{{template "admin/top.html" .}} +

Open Register

+ +
+ +
+
+
+
+
+ + +
+
+ + +
+
+
+ +
+ +{{template "admin/footer.html" .}} + + + +{{template "admin/end.html" .}} \ No newline at end of file diff --git a/app/views/Admin/nav.html b/app/views/Admin/nav.html index 6093526..dbc2be6 100644 --- a/app/views/Admin/nav.html +++ b/app/views/Admin/nav.html @@ -140,6 +140,14 @@ +
  • + + + Open Register + + +
  • +
  • diff --git a/app/views/Home/login.html b/app/views/Home/login.html index 6b71b99..4b5a8ec 100644 --- a/app/views/Home/login.html +++ b/app/views/Home/login.html @@ -38,9 +38,11 @@ {{msg . "forgetPassword"}} +
    @@ -48,9 +50,8 @@ {{if .openRegister}} {{msg . "register"}} - {{end}} - {{msg . "or"}} + {{end}} {{msg . "try"}} diff --git a/conf/app.conf-default b/conf/app.conf-default index 595c005..649c8b5 100644 --- a/conf/app.conf-default +++ b/conf/app.conf-default @@ -6,9 +6,6 @@ http.port=80 site.url=http://localhost # or http://x.com:8080, http://www.xx.com:9000 -# the administrator username -adminUsername=admin - # mongdb db.host=localhost db.port=27017 diff --git a/conf/routes-default b/conf/routes-default deleted file mode 100644 index b2ae56e..0000000 --- a/conf/routes-default +++ /dev/null @@ -1,55 +0,0 @@ -# Routes -# This file defines all application routes (Higher priority routes first) -# ~~~~ - -module:testrunner - -# Home is My Blog -Get / Blog.Index -GET /note Note.Index -# leanote home -GET /index Index.Index - -GET /login Auth.Login -POST /doLogin Auth.DoLogin -GET /logout Auth.Logout -Get /demo Auth.Demo - -Get /register Auth.Register -POST /doRegister Auth.DoRegister - -GET /findPassword/:token Auth.FindPassword2 -GET /findPassword Auth.FindPassword -POST /doFindPassword Auth.DoFindPassword -POST /findPasswordUpdate Auth.FindPasswordUpdate - -# mobile -GET /mobile Mobile.Index - -# blog -# /blog/view/:noteId必须要放在/blog/:userId...之前 -GET /blog/searchBlog/:userId Blog.SearchBlog -GET /blog/set Blog.Set -GET /blog/aboutMe/:userId Blog.AboutMe -POST /blog/setUserBlogBase Blog.SetUserBlogBase -POST /blog/setUserBlogComment Blog.SetUserBlogComment -POST /blog/setUserBlogStyle Blog.SetUserBlogStyle -GET /blog/view/:noteId Blog.View -GET /blog/:userId Blog.Index -GET /blog/:userId/:notebookId Blog.Index -GET /blog Blog.Index - -# Map static resources from the /app/public folder to the /public path -GET /favicon.ico Static.Serve("public/images/favicon.ico") -GET /public/*filepath Static.Serve("public") -GET /js/*filepath Static.Serve("public/js") -GET /images/*filepath Static.Serve("public/images") -GET /img/*filepath Static.Serve("public/img") -GET /css/*filepath Static.Serve("public/css") -GET /fonts/*filepath Static.Serve("public/fonts") -GET /tinymce/*filepath Static.Serve("public/tinymce") -#GET /plugins/*filepath Static.Serve("public/tinymce/plugins") -GET /upload/*filepath Static.Serve("public/upload") - -# common -* /:controller/:action :controller.:action \ No newline at end of file