siteurl, adminUsername config in configService
This commit is contained in:
@ -183,7 +183,7 @@ func (c BaseController) SetLocale() string {
|
||||
lang = "en";
|
||||
}
|
||||
c.RenderArgs["locale"] = lang;
|
||||
c.RenderArgs["siteUrl"] = siteUrl;
|
||||
c.RenderArgs["siteUrl"] = configService.GetSiteUrl();
|
||||
|
||||
c.RenderArgs["blogUrl"] = configService.GetBlogUrl()
|
||||
c.RenderArgs["leaUrl"] = configService.GetLeaUrl()
|
||||
@ -196,7 +196,7 @@ func (c BaseController) SetLocale() string {
|
||||
func (c BaseController) SetUserInfo() {
|
||||
userInfo := c.GetUserInfo()
|
||||
c.RenderArgs["userInfo"] = userInfo
|
||||
if(userInfo.Username == adminUsername) {
|
||||
if(userInfo.Username == configService.GetAdminUsername()) {
|
||||
c.RenderArgs["isAdmin"] = true
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ func (c Blog) setPreviewUrl() {
|
||||
themeId := c.Session["themeId"]
|
||||
theme := themeService.GetTheme(userId, themeId)
|
||||
|
||||
siteUrl := configService.GetSiteUrl()
|
||||
blogUrl := siteUrl + "/preview" // blog.leanote.com
|
||||
userIdOrEmail := userId
|
||||
|
||||
@ -137,6 +138,7 @@ func (c Blog) setUrl(userBlog info.UserBlog, userInfo info.User) {
|
||||
staticUrl = configService.GetUserUrl(strings.Split(host, ":")[0])
|
||||
// staticUrl == host, 为保证同源!!! 只有host, http://leanote.com, http://blog/leanote.com
|
||||
// life.leanote.com, lealife.com
|
||||
siteUrl := configService.GetSiteUrl()
|
||||
if userBlog.Domain != "" && configService.AllowCustomDomain() {
|
||||
// ok
|
||||
indexUrl = configService.GetUserUrl(userBlog.Domain)
|
||||
@ -496,7 +498,7 @@ func (c Blog) Archive(userIdOrEmail string, cateId string) (re revel.Result) {
|
||||
|
||||
// 用户id为空, 转至博客平台
|
||||
if userIdOrEmail == "" {
|
||||
userIdOrEmail = leanoteUserId
|
||||
userIdOrEmail = configService.GetAdminUsername()
|
||||
}
|
||||
var userInfo info.User
|
||||
if userId != "" {
|
||||
@ -594,7 +596,7 @@ func (c Blog) Index(userIdOrEmail string) (re revel.Result) {
|
||||
|
||||
// 用户id为空, 转至博客平台
|
||||
if userIdOrEmail == "" {
|
||||
userIdOrEmail = leanoteUserId
|
||||
userIdOrEmail = configService.GetAdminUsername()
|
||||
}
|
||||
var userInfo info.User
|
||||
if userId != "" {
|
||||
|
@ -316,7 +316,7 @@ func (c File) UploadImage(renderHtml string) revel.Result {
|
||||
|
||||
re := c.uploadImage("", "");
|
||||
|
||||
c.RenderArgs["fileUrlPath"] = siteUrl + re.Id
|
||||
c.RenderArgs["fileUrlPath"] = configService.GetSiteUrl() + re.Id
|
||||
c.RenderArgs["resultCode"] = re.Code
|
||||
c.RenderArgs["resultMsg"] = re.Msg
|
||||
|
||||
|
@ -53,7 +53,8 @@ func (c Note) Index() revel.Result {
|
||||
}
|
||||
// 当然, 还需要得到第一个notes的content
|
||||
//...
|
||||
c.RenderArgs["isAdmin"] = leanoteUserId == userInfo.Username
|
||||
Log(configService.GetAdminUsername())
|
||||
c.RenderArgs["isAdmin"] = configService.GetAdminUsername() == userInfo.Username
|
||||
|
||||
c.RenderArgs["userInfo"] = userInfo
|
||||
c.RenderArgs["userInfoJson"] = c.Json(userInfo)
|
||||
@ -299,7 +300,7 @@ func (c Note) Html2Image(noteId string) revel.Result {
|
||||
appKey, _ := revel.Config.String("app.secret")
|
||||
cookieDomain, _ := revel.Config.String("cookie.domain")
|
||||
// 生成之
|
||||
url := siteUrl + "/note/toImage?noteId=" + noteId + "&appKey=" + appKey;
|
||||
url := configService.GetSiteUrl() + "/note/toImage?noteId=" + noteId + "&appKey=" + appKey;
|
||||
// /Users/life/Documents/bin/phantomjs/bin/phantomjs /Users/life/Desktop/test/b.js
|
||||
binPath := configService.GetGlobalStringConfig("toImageBinPath")
|
||||
if binPath == "" {
|
||||
|
@ -3,7 +3,7 @@ package admin
|
||||
import (
|
||||
"github.com/revel/revel"
|
||||
// "encoding/json"
|
||||
// . "github.com/leanote/leanote/app/lea"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
// "io/ioutil"
|
||||
)
|
||||
|
||||
@ -16,3 +16,9 @@ func (c AdminUpgrade) UpgradeBlog() revel.Result {
|
||||
upgradeService.UpgradeBlog()
|
||||
return nil;
|
||||
}
|
||||
|
||||
func (c AdminUpgrade) UpgradeBetaToSelfBlog() revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Msg = upgradeService.UpgradeBetaToSelfBlog(c.GetUserId())
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ var configService *service.ConfigService
|
||||
var emailService *service.EmailService
|
||||
var upgradeService *service.UpgradeService
|
||||
|
||||
var adminUsername = "admin"
|
||||
// 拦截器
|
||||
// 不需要拦截的url
|
||||
// Index 除了Note之外都不需要
|
||||
@ -83,7 +82,7 @@ func AuthInterceptor(c *revel.Controller) revel.Result {
|
||||
|
||||
// 验证是否已登录
|
||||
// 必须是管理员
|
||||
if username, ok := c.Session["Username"]; ok && username == adminUsername {
|
||||
if username, ok := c.Session["Username"]; ok && username == configService.GetAdminUsername() {
|
||||
return nil // 已登录
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,6 @@ var themeService *service.ThemeService
|
||||
|
||||
var pageSize = 1000
|
||||
var defaultSortField = "UpdatedTime"
|
||||
var leanoteUserId = "admin" // 不能更改
|
||||
var adminUsername = "admin"
|
||||
var siteUrl = "http://leanote.com"
|
||||
|
||||
// 拦截器
|
||||
// 不需要拦截的url
|
||||
@ -56,10 +53,14 @@ var commonUrl = map[string]map[string]bool{"Index": map[string]bool{"Index": tru
|
||||
"View": true,
|
||||
"AboutMe": true,
|
||||
"Cate": true,
|
||||
"ListCateLatest": true,
|
||||
"Search": true,
|
||||
"GetLikeAndComments": true,
|
||||
"IncReadNum": true,
|
||||
"ListComments": true,
|
||||
"Single": true,
|
||||
"Archive": true,
|
||||
"Tags": true,
|
||||
},
|
||||
// 用户的激活与修改邮箱都不需要登录, 通过链接地址
|
||||
"User": map[string]bool{"UpdateEmail": true,
|
||||
@ -69,6 +70,7 @@ var commonUrl = map[string]map[string]bool{"Index": map[string]bool{"Index": tru
|
||||
"File": map[string]bool{"OutputImage": true, "OutputFile": true},
|
||||
"Attach": map[string]bool{"Download": true, "DownloadAll": true},
|
||||
}
|
||||
|
||||
func needValidate(controller, method string) bool {
|
||||
// 在里面
|
||||
if v, ok := commonUrl[controller]; ok {
|
||||
@ -79,7 +81,7 @@ func needValidate(controller, method string) bool {
|
||||
return true
|
||||
} else {
|
||||
// controller不在这里的, 肯定要验证
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}
|
||||
func AuthInterceptor(c *revel.Controller) revel.Result {
|
||||
@ -132,6 +134,11 @@ func InitService() {
|
||||
themeService = service.ThemeS
|
||||
}
|
||||
|
||||
// 初始化博客模板
|
||||
// 博客模板不由revel的
|
||||
func initBlogTemplate() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
// interceptor
|
||||
// revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Index{}) // Index.Note自己校验
|
||||
@ -141,11 +148,10 @@ func init() {
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &User{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &File{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Attach{})
|
||||
// revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Blog{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &NoteContentHistory{})
|
||||
|
||||
revel.OnAppStart(func() {
|
||||
siteUrl, _ = revel.Config.String("site.url")
|
||||
|
||||
// 博客初始化模板
|
||||
blog.Init()
|
||||
})
|
||||
|
@ -29,7 +29,6 @@ var emailService *service.EmailService
|
||||
var upgradeService *service.UpgradeService
|
||||
var themeService *service.ThemeService
|
||||
|
||||
var adminUsername = "admin"
|
||||
// 拦截器
|
||||
// 不需要拦截的url
|
||||
// Index 除了Note之外都不需要
|
||||
@ -128,6 +127,5 @@ func init() {
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &MemberUser{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &MemberBlog{})
|
||||
revel.OnAppStart(func() {
|
||||
adminUsername, _ = revel.Config.String("adminUsername")
|
||||
})
|
||||
}
|
@ -429,7 +429,7 @@ func (this *BlogService) fixUserBlog(userBlog *info.UserBlog) {
|
||||
// Logo路径问题, 有些有http: 有些没有
|
||||
if userBlog.Logo != "" && !strings.HasPrefix(userBlog.Logo, "http") {
|
||||
userBlog.Logo = strings.Trim(userBlog.Logo, "/")
|
||||
userBlog.Logo = siteUrl + "/" + userBlog.Logo
|
||||
userBlog.Logo = configService.GetSiteUrl() + "/" + userBlog.Logo
|
||||
}
|
||||
|
||||
if userBlog.SortField == "" {
|
||||
@ -691,7 +691,7 @@ func (this *BlogService) DeleteComment(noteId, commentId, userId string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if userId == adminUserId || note.UserId.Hex() == userId || comment.UserId.Hex() == userId {
|
||||
if userId == configService.GetAdminUserId() || note.UserId.Hex() == userId || comment.UserId.Hex() == userId {
|
||||
if db.Delete(db.BlogComments, bson.M{"_id": bson.ObjectIdHex(commentId)}) {
|
||||
// 评论-1
|
||||
db.Update(db.Notes, bson.M{"_id": bson.ObjectIdHex(noteId)}, bson.M{"$inc": bson.M{"CommentNum": -1}})
|
||||
|
@ -17,6 +17,9 @@ import (
|
||||
// 配置服务
|
||||
// 只是全局的, 用户的配置没有
|
||||
type ConfigService struct {
|
||||
adminUserId string
|
||||
siteUrl string
|
||||
adminUsername string
|
||||
// 全局的
|
||||
GlobalAllConfigs map[string]interface{}
|
||||
GlobalStringConfigs map[string]string
|
||||
@ -24,9 +27,6 @@ type ConfigService struct {
|
||||
GlobalMapConfigs map[string]map[string]string
|
||||
GlobalArrMapConfigs map[string][]map[string]string
|
||||
}
|
||||
|
||||
var adminUserId = ""
|
||||
|
||||
// appStart时 将全局的配置从数据库中得到作为全局
|
||||
func (this *ConfigService) InitGlobalConfigs() bool {
|
||||
this.GlobalAllConfigs = map[string]interface{}{}
|
||||
@ -35,16 +35,17 @@ func (this *ConfigService) InitGlobalConfigs() bool {
|
||||
this.GlobalMapConfigs = map[string]map[string]string{}
|
||||
this.GlobalArrMapConfigs = map[string][]map[string]string{}
|
||||
|
||||
adminUsername, _ := revel.Config.String("adminUsername")
|
||||
if adminUsername == "" {
|
||||
adminUsername = "admin"
|
||||
this.adminUsername, _ = revel.Config.String("adminUsername")
|
||||
if this.adminUsername == "" {
|
||||
this.adminUsername = "admin"
|
||||
}
|
||||
this.siteUrl, _ = revel.Config.String("site.url")
|
||||
|
||||
userInfo := userService.GetUserInfoByAny(adminUsername)
|
||||
userInfo := userService.GetUserInfoByAny(this.adminUsername)
|
||||
if userInfo.UserId == "" {
|
||||
return false
|
||||
}
|
||||
adminUserId = userInfo.UserId.Hex()
|
||||
this.adminUserId = userInfo.UserId.Hex()
|
||||
|
||||
configs := []info.Config{}
|
||||
db.ListByQ(db.Configs, bson.M{"UserId": userInfo.UserId}, &configs)
|
||||
@ -68,6 +69,16 @@ func (this *ConfigService) InitGlobalConfigs() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *ConfigService) GetSiteUrl() string {
|
||||
return this.siteUrl;
|
||||
}
|
||||
func (this *ConfigService) GetAdminUsername() string {
|
||||
return this.adminUsername
|
||||
}
|
||||
func (this *ConfigService) GetAdminUserId() string {
|
||||
return this.adminUserId
|
||||
}
|
||||
|
||||
// 通用方法
|
||||
func (this *ConfigService) updateGlobalConfig(userId, key string, value interface{}, isArr, isMap, isArrMap bool) bool {
|
||||
// 判断是否存在
|
||||
@ -183,7 +194,7 @@ func (this *ConfigService) UpdateShareNoteConfig(registerSharedUserId string,
|
||||
if registerSharedUserId == "" {
|
||||
ok = true
|
||||
msg = "share userId is blank, So it share nothing to register"
|
||||
this.UpdateGlobalStringConfig(adminUserId, "registerSharedUserId", "")
|
||||
this.UpdateGlobalStringConfig(this.adminUserId, "registerSharedUserId", "")
|
||||
return
|
||||
} else {
|
||||
user := userService.GetUserInfo(registerSharedUserId)
|
||||
@ -192,7 +203,7 @@ func (this *ConfigService) UpdateShareNoteConfig(registerSharedUserId string,
|
||||
msg = "no such user: " + registerSharedUserId
|
||||
return
|
||||
} else {
|
||||
this.UpdateGlobalStringConfig(adminUserId, "registerSharedUserId", registerSharedUserId)
|
||||
this.UpdateGlobalStringConfig(this.adminUserId, "registerSharedUserId", registerSharedUserId)
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +230,7 @@ func (this *ConfigService) UpdateShareNoteConfig(registerSharedUserId string,
|
||||
}
|
||||
}
|
||||
}
|
||||
this.UpdateGlobalArrMapConfig(adminUserId, "registerSharedNotebooks", notebooks)
|
||||
this.UpdateGlobalArrMapConfig(this.adminUserId, "registerSharedNotebooks", notebooks)
|
||||
|
||||
notes := []map[string]string{}
|
||||
// 共享笔记
|
||||
@ -244,7 +255,7 @@ func (this *ConfigService) UpdateShareNoteConfig(registerSharedUserId string,
|
||||
}
|
||||
}
|
||||
}
|
||||
this.UpdateGlobalArrMapConfig(adminUserId, "registerSharedNotes", notes)
|
||||
this.UpdateGlobalArrMapConfig(this.adminUserId, "registerSharedNotes", notes)
|
||||
|
||||
// 复制
|
||||
noteIds := []string{}
|
||||
@ -265,7 +276,7 @@ func (this *ConfigService) UpdateShareNoteConfig(registerSharedUserId string,
|
||||
}
|
||||
}
|
||||
}
|
||||
this.UpdateGlobalArrayConfig(adminUserId, "registerCopyNoteIds", noteIds)
|
||||
this.UpdateGlobalArrayConfig(this.adminUserId, "registerCopyNoteIds", noteIds)
|
||||
|
||||
ok = true
|
||||
return
|
||||
@ -277,7 +288,7 @@ func (this *ConfigService) AddBackup(path, remark string) bool {
|
||||
n := time.Now().Unix()
|
||||
nstr := fmt.Sprintf("%v", n)
|
||||
backups = append(backups, map[string]string{"createdTime": nstr, "path": path, "remark": remark})
|
||||
return this.UpdateGlobalArrMapConfig(adminUserId, "backups", backups)
|
||||
return this.UpdateGlobalArrMapConfig(this.adminUserId, "backups", backups)
|
||||
}
|
||||
|
||||
func (this *ConfigService) getBackupDirname() string {
|
||||
@ -349,7 +360,7 @@ func (this *ConfigService) Restore(createdTime string) (ok bool, msg string) {
|
||||
port, _ := revel.Config.String("db.port")
|
||||
username, _ := revel.Config.String("db.username")
|
||||
password, _ := revel.Config.String("db.password")
|
||||
// mongorestore -h localhost -d leanote -o /root/mongodb_backup/leanote-9-22/ -u leanote -p kk
|
||||
// mongorestore -h localhost -d leanote -o /root/mongodb_backup/leanote-9-22/ -u leanote -p nKFAkxKnWkEQy8Vv2LlM
|
||||
binPath = binPath + " --drop -h " + host + " -d " + dbname + " -port " + port
|
||||
if username != "" {
|
||||
binPath += " -u " + username + " -p " + password
|
||||
@ -398,7 +409,7 @@ func (this *ConfigService) DeleteBackup(createdTime string) (bool, string) {
|
||||
// 删除之
|
||||
backups = append(backups[0:i], backups[i+1:]...)
|
||||
|
||||
ok := this.UpdateGlobalArrMapConfig(adminUserId, "backups", backups)
|
||||
ok := this.UpdateGlobalArrMapConfig(this.adminUserId, "backups", backups)
|
||||
return ok, ""
|
||||
}
|
||||
|
||||
@ -416,7 +427,7 @@ func (this *ConfigService) UpdateBackupRemark(createdTime, remark string) (bool,
|
||||
}
|
||||
backup["remark"] = remark;
|
||||
|
||||
ok := this.UpdateGlobalArrMapConfig(adminUserId, "backups", backups)
|
||||
ok := this.UpdateGlobalArrMapConfig(this.adminUserId, "backups", backups)
|
||||
return ok, ""
|
||||
}
|
||||
|
||||
@ -451,7 +462,7 @@ func init() {
|
||||
port = "";
|
||||
}
|
||||
|
||||
siteUrl, _ = revel.Config.String("site.url") // 已包含:9000, http, 去掉成 leanote.com
|
||||
siteUrl, _ := revel.Config.String("site.url") // 已包含:9000, http, 去掉成 leanote.com
|
||||
if strings.HasPrefix(siteUrl, "http://") {
|
||||
defaultDomain = siteUrl[len("http://"):]
|
||||
} else if strings.HasPrefix(siteUrl, "https://") {
|
||||
|
@ -82,9 +82,9 @@ func (this *EmailService) RegisterSendActiveEmail(userInfo info.User, email stri
|
||||
return false
|
||||
}
|
||||
|
||||
tokenUrl := siteUrl + "/user/activeEmail?token=" + token
|
||||
tokenUrl := configService.GetSiteUrl() + "/user/activeEmail?token=" + token
|
||||
// {siteUrl} {tokenUrl} {token} {tokenTimeout} {user.id} {user.email} {user.username}
|
||||
token2Value := map[string]interface{}{"siteUrl": siteUrl, "tokenUrl": tokenUrl, "token": token, "tokenTimeout": strconv.Itoa(int(tokenService.GetOverHours(info.TokenActiveEmail))),
|
||||
token2Value := map[string]interface{}{"siteUrl": configService.GetSiteUrl(), "tokenUrl": tokenUrl, "token": token, "tokenTimeout": strconv.Itoa(int(tokenService.GetOverHours(info.TokenActiveEmail))),
|
||||
"user": map[string]interface{}{
|
||||
"userId": userInfo.UserId.Hex(),
|
||||
"email": userInfo.Email,
|
||||
@ -122,9 +122,9 @@ func (this *EmailService) UpdateEmailSendActiveEmail(userInfo info.User, email s
|
||||
tpl := configService.GetGlobalStringConfig("emailTemplateUpdateEmail");
|
||||
|
||||
// 发送邮件
|
||||
tokenUrl := siteUrl + "/user/updateEmail?token=" + token
|
||||
tokenUrl := configService.GetSiteUrl() + "/user/updateEmail?token=" + token
|
||||
// {siteUrl} {tokenUrl} {token} {tokenTimeout} {user.userId} {user.email} {user.username}
|
||||
token2Value := map[string]interface{}{"siteUrl": siteUrl, "tokenUrl": tokenUrl, "token": token, "tokenTimeout": strconv.Itoa(int(tokenService.GetOverHours(info.TokenActiveEmail))),
|
||||
token2Value := map[string]interface{}{"siteUrl": configService.GetSiteUrl(), "tokenUrl": tokenUrl, "token": token, "tokenTimeout": strconv.Itoa(int(tokenService.GetOverHours(info.TokenActiveEmail))),
|
||||
"newEmail": email,
|
||||
"user": map[string]interface{}{
|
||||
"userId": userInfo.UserId.Hex(),
|
||||
@ -148,9 +148,9 @@ func (this *EmailService) FindPwdSendEmail(token, email string) (ok bool, msg st
|
||||
tpl := configService.GetGlobalStringConfig("emailTemplateFindPassword");
|
||||
|
||||
// 发送邮件
|
||||
tokenUrl := siteUrl + "/findPassword/" + token
|
||||
tokenUrl := configService.GetSiteUrl() + "/findPassword/" + token
|
||||
// {siteUrl} {tokenUrl} {token} {tokenTimeout} {user.id} {user.email} {user.username}
|
||||
token2Value := map[string]interface{}{"siteUrl": siteUrl, "tokenUrl": tokenUrl,
|
||||
token2Value := map[string]interface{}{"siteUrl": configService.GetSiteUrl(), "tokenUrl": tokenUrl,
|
||||
"token": token, "tokenTimeout": strconv.Itoa(int(tokenService.GetOverHours(info.TokenActiveEmail)))}
|
||||
|
||||
ok, msg, subject, tpl = this.renderEmail(subject, tpl, token2Value)
|
||||
@ -167,8 +167,8 @@ func (this *EmailService) SendInviteEmail(userInfo info.User, email, content str
|
||||
subject := configService.GetGlobalStringConfig("emailTemplateInviteSubject");
|
||||
tpl := configService.GetGlobalStringConfig("emailTemplateInvite");
|
||||
|
||||
token2Value := map[string]interface{}{"siteUrl": siteUrl,
|
||||
"registerUrl": siteUrl + "/register?from=" + userInfo.Username,
|
||||
token2Value := map[string]interface{}{"siteUrl": configService.GetSiteUrl(),
|
||||
"registerUrl": configService.GetSiteUrl() + "/register?from=" + userInfo.Username,
|
||||
"content": content,
|
||||
"user": map[string]interface{}{
|
||||
"username": userInfo.Username,
|
||||
@ -225,7 +225,7 @@ func (this *EmailService) SendCommentEmail(note info.Note, comment info.BlogComm
|
||||
// {blog.id} {blog.title} {blog.url}
|
||||
// {commentUser.userId} {commentUser.username} {commentUser.email}
|
||||
// {commentedUser.userId} {commentedUser.username} {commentedUser.email}
|
||||
token2Value := map[string]interface{}{"siteUrl": siteUrl, "blogUrl": configService.GetBlogUrl(),
|
||||
token2Value := map[string]interface{}{"siteUrl": configService.GetSiteUrl(), "blogUrl": configService.GetBlogUrl(),
|
||||
"blog": map[string]string{
|
||||
"id": note.NoteId.Hex(),
|
||||
"title": note.Title,
|
||||
@ -316,7 +316,7 @@ func (this *EmailService) renderEmail(subject, body string, values map[string]in
|
||||
|
||||
var tpl *template.Template
|
||||
|
||||
values["siteUrl"] = siteUrl;
|
||||
values["siteUrl"] = configService.GetSiteUrl();
|
||||
|
||||
// subject
|
||||
if subject != "" {
|
||||
|
@ -362,7 +362,7 @@ func (this *ThemeService) DeleteTheme(userId, themeId string) (ok bool) {
|
||||
func (this *ThemeService) PublicTheme(userId, themeId string) (ok bool) {
|
||||
// 是否是管理员?
|
||||
userInfo := userService.GetUserInfo(userId)
|
||||
if userInfo.Username == adminUsername {
|
||||
if userInfo.Username == configService.GetAdminUsername() {
|
||||
theme := this.GetThemeById(themeId)
|
||||
return db.UpdateByQField(db.Themes, bson.M{"UserId": bson.ObjectIdHex(userId), "_id": bson.ObjectIdHex(themeId)}, "IsDefault", !theme.IsDefault)
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func (this *UserService) setUserLogo(user *info.User) {
|
||||
}
|
||||
if user.Logo != "" && !strings.HasPrefix(user.Logo, "http") {
|
||||
user.Logo = strings.Trim(user.Logo, "/")
|
||||
user.Logo = siteUrl + "/" + user.Logo
|
||||
user.Logo = configService.GetSiteUrl() + "/" + user.Logo
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,8 +256,7 @@ func (this *UserService) UpdatePwd(userId, oldPwd, pwd string) (bool, string) {
|
||||
|
||||
// 管理员重置密码
|
||||
func (this *UserService) ResetPwd(adminUserId, userId, pwd string) (ok bool, msg string) {
|
||||
adminInfo := this.GetUserInfoByAny(adminUsername)
|
||||
if adminInfo.UserId.Hex() != adminUserId {
|
||||
if configService.GetAdminUserId() != adminUserId {
|
||||
return
|
||||
}
|
||||
ok = db.UpdateByQField(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, "Pwd", Md5(pwd))
|
||||
|
@ -1,7 +1,6 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/revel/revel"
|
||||
)
|
||||
|
||||
// init service, for share service bettween services
|
||||
@ -30,9 +29,6 @@ var UpgradeS *UpgradeService
|
||||
var SessionS, sessionService *SessionService
|
||||
var ThemeS, themeService *ThemeService
|
||||
|
||||
var siteUrl string
|
||||
var adminUsername = "admin"
|
||||
|
||||
// onAppStart调用
|
||||
func InitService() {
|
||||
NotebookS = &NotebookService{}
|
||||
@ -74,6 +70,4 @@ func InitService() {
|
||||
emailService = EmailS
|
||||
sessionService = SessionS
|
||||
themeService = ThemeS
|
||||
|
||||
siteUrl, _ = revel.Config.String("site.url")
|
||||
}
|
@ -242,6 +242,8 @@ latest=Latest
|
||||
|
||||
# 用户中心
|
||||
memberCenter=Member Center
|
||||
userNotExists=该成员沿未注册
|
||||
hasUsers=已存在该成员
|
||||
|
||||
# error
|
||||
notFound=This page cann't found.
|
||||
|
@ -268,6 +268,8 @@ latest=最新
|
||||
|
||||
# 用户中心
|
||||
memberCenter=用户中心
|
||||
userNotExists=该成员沿未注册
|
||||
hasUsers=已存在该成员
|
||||
|
||||
# 必须要加这个, 奇怪
|
||||
[CN]
|
Reference in New Issue
Block a user