v1.0 fixed
This commit is contained in:
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
})
|
||||
}
|
@ -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,
|
||||
|
@ -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}");
|
||||
}();
|
||||
}
|
||||
|
||||
|
48
app/views/Admin/Setting/openRegister.html
Normal file
48
app/views/Admin/Setting/openRegister.html
Normal file
@ -0,0 +1,48 @@
|
||||
{{template "admin/top.html" .}}
|
||||
<div class="m-b-md"> <h3 class="m-b-none">Open Register</h3></div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-6">
|
||||
<form id="form_data">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label>Open ?</label>
|
||||
<input type="checkbox" class="form-control" name="openRegister" {{if .str.openRegister}}checked="checked"{{end}} value="1">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="panel-footer text-right bg-light lter">
|
||||
<button type="submit" id="submit" class="btn btn-success btn-s-xs">Submit</button>
|
||||
</footer>
|
||||
</section>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{template "admin/footer.html" .}}
|
||||
<script src="/public/admin/js/jquery-validation-1.13.0/jquery.validate.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
init_validator("#form_data");
|
||||
$("#submit").click(function(e){
|
||||
e.preventDefault();
|
||||
var t = this;
|
||||
if($("#form_data").valid()) {
|
||||
$(t).button('loading');
|
||||
ajaxPost("/adminSetting/openRegister", getFormJsonData("form_data"), function(ret){
|
||||
$(t).button('reset')
|
||||
if(!ret.Ok) {
|
||||
art.alert(ret.Msg)
|
||||
} else {
|
||||
art.tips("Success");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{{template "admin/end.html" .}}
|
@ -140,6 +140,14 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/admin/t?t=setting/openRegister">
|
||||
<span>
|
||||
Open Register
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/admin/t?t=setting/shareNote">
|
||||
<span>
|
||||
|
@ -38,9 +38,11 @@
|
||||
<a href="/findPassword" class="pull-right m-t-xs"><small>{{msg . "forgetPassword"}}</small></a>
|
||||
<button id="loginBtn" class="btn btn-success">{{msg . "login"}}</button>
|
||||
</div>
|
||||
<!--
|
||||
<div class="line line-dashed"></div>
|
||||
|
||||
<a href="#" id="github" class="btn btn-github btn-block m-b-sm"><i class="fa fa-github pull-left"></i>{{msg . "use"}} Github</a>
|
||||
-->
|
||||
|
||||
<div class="line line-dashed"></div>
|
||||
|
||||
@ -48,9 +50,8 @@
|
||||
|
||||
{{if .openRegister}}
|
||||
<a href="/register" class="btn btn-default btn-block">{{msg . "register"}}</a>
|
||||
{{end}}
|
||||
|
||||
{{msg . "or"}}
|
||||
{{end}}
|
||||
|
||||
<a id="loginBtn" href="/demo" class="btn btn-default btn-block">{{msg . "try"}}</a>
|
||||
</form>
|
||||
|
@ -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
|
||||
|
@ -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
|
Reference in New Issue
Block a user