mirror of
https://gitee.com/doramart/DoraCMS.git
synced 2024-12-02 12:17:48 +08:00
添加了找回密码功能,同事修复了之前的部分bug
This commit is contained in:
parent
983eec503f
commit
8378f84979
10
app.js
10
app.js
@ -19,7 +19,7 @@ var validat = require('./routes/validat');
|
||||
//系统功能支持
|
||||
var system = require('./routes/system');
|
||||
//站点配置
|
||||
var Settings = require("./models/db/settings");
|
||||
var settings = require("./models/db/settings");
|
||||
var siteFunc = require("./models/db/siteFunc");
|
||||
//文件操作对象
|
||||
var fs = require('fs');
|
||||
@ -58,16 +58,16 @@ app.use(partials());
|
||||
app.use(logger('dev'));
|
||||
app.use(bodyParser.json({limit: '50mb'})); // 限制上传5M
|
||||
app.use(bodyParser.urlencoded({ extended: false , limit: '50mb' }));
|
||||
app.use(cookieParser(Settings.session_secret));
|
||||
app.use(cookieParser(settings.session_secret));
|
||||
//解决异步层次混乱问题
|
||||
app.use(require('express-promise')());
|
||||
|
||||
|
||||
app.use(session({
|
||||
secret: Settings.session_secret,
|
||||
secret: settings.session_secret,
|
||||
store: new RedisStore({
|
||||
port: Settings.redis_port,
|
||||
host: Settings.redis_host,
|
||||
port: settings.redis_port,
|
||||
host: settings.redis_host,
|
||||
ttl: 1800 // 过期时间
|
||||
}),
|
||||
resave: true,
|
||||
|
@ -7,9 +7,9 @@ var url = require('url');
|
||||
var crypto = require("crypto");
|
||||
var mongoose = require('mongoose');
|
||||
//站点配置
|
||||
var Settings = require("../models/db/settings");
|
||||
var settings = require("../models/db/settings");
|
||||
var db = mongoose.connect('mongodb://localhost/doracms');
|
||||
//mongoose.connect('mongodb://'+Settings.USERNAME+':'+Settings.PASSWORD+'@'+Settings.HOST+':'+Settings.PORT+'/'+Settings.DB+'');
|
||||
//mongoose.connect('mongodb://'+settings.USERNAME+':'+settings.PASSWORD+'@'+settings.HOST+':'+settings.PORT+'/'+settings.DB+'');
|
||||
|
||||
//信息删除操作
|
||||
|
||||
@ -174,6 +174,12 @@ var DbOpt = {
|
||||
|
||||
},
|
||||
|
||||
getKeyArrByTokenId : function(tokenId){
|
||||
var newLink = DbOpt.decrypt(tokenId,settings.encrypt_key);
|
||||
var keyArr = newLink.split('$');
|
||||
return keyArr;
|
||||
},
|
||||
|
||||
getCount : function(obj,req,res,conditions){ // 查询指定对象的数量
|
||||
obj.count(conditions, function (err, count) {
|
||||
if (err){
|
||||
|
@ -27,7 +27,8 @@ var User = mongoose.model('User', {
|
||||
province : String, // 所在省份
|
||||
city : String, // 所在城市
|
||||
year : Number, // 出生年
|
||||
openid : String // 针对qq互联
|
||||
openid : String, // 针对qq互联
|
||||
retrieve_time : {type: Number} // 用户发送激活请求的时间
|
||||
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Created by Administrator on 2015/8/31.
|
||||
*/
|
||||
var url = require('url');
|
||||
var Settings = require("./settings");
|
||||
var settings = require("./settings");
|
||||
//数据库操作对象
|
||||
var DbOpt = require("../Dbopt");
|
||||
|
||||
@ -36,7 +36,7 @@ var adminFunc = {
|
||||
siteInfos : function (description) {
|
||||
|
||||
return {
|
||||
title : Settings.SITETITLE,
|
||||
title : settings.SITETITLE,
|
||||
description : description
|
||||
}
|
||||
},
|
||||
@ -84,29 +84,29 @@ var adminFunc = {
|
||||
getTargetObj : function(currentPage){
|
||||
var targetObj;
|
||||
|
||||
if(currentPage == Settings.ADMINUSERLIST[0]){
|
||||
if(currentPage == settings.ADMINUSERLIST[0]){
|
||||
targetObj = AdminUser;
|
||||
}else if(currentPage == Settings.ADMINGROUPLIST[0]){
|
||||
}else if(currentPage == settings.ADMINGROUPLIST[0]){
|
||||
targetObj = AdminGroup;
|
||||
}else if(currentPage == Settings.EMAILTEMPLIST[0]){
|
||||
}else if(currentPage == settings.EMAILTEMPLIST[0]){
|
||||
targetObj = EmailTemp;
|
||||
}else if(currentPage == Settings.ADSLIST[0]){
|
||||
}else if(currentPage == settings.ADSLIST[0]){
|
||||
targetObj = Ads;
|
||||
}else if(currentPage == Settings.FILESLIST[0]){
|
||||
}else if(currentPage == settings.FILESLIST[0]){
|
||||
targetObj = Files;
|
||||
}else if(currentPage == Settings.DATAMANAGE[0]){
|
||||
}else if(currentPage == settings.DATAMANAGE[0]){
|
||||
targetObj = DataOptionLog;
|
||||
}else if(currentPage == Settings.CONTENTLIST[0]){
|
||||
}else if(currentPage == settings.CONTENTLIST[0]){
|
||||
targetObj = Content;
|
||||
}else if(currentPage == Settings.CONTENTCATEGORYS[0]){
|
||||
}else if(currentPage == settings.CONTENTCATEGORYS[0]){
|
||||
targetObj = ContentCategory;
|
||||
}else if(currentPage == Settings.CONTENTTAGS[0]){
|
||||
}else if(currentPage == settings.CONTENTTAGS[0]){
|
||||
targetObj = ContentTags;
|
||||
}else if(currentPage == Settings.CONTENTTEMPS[0]){
|
||||
}else if(currentPage == settings.CONTENTTEMPS[0]){
|
||||
targetObj = ContentTemplate;
|
||||
}else if(currentPage == Settings.MESSAGEMANAGE[0]){
|
||||
}else if(currentPage == settings.MESSAGEMANAGE[0]){
|
||||
targetObj = Message;
|
||||
}else if(currentPage == Settings.REGUSERSLIST[0]){
|
||||
}else if(currentPage == settings.REGUSERSLIST[0]){
|
||||
targetObj = User;
|
||||
}else{
|
||||
targetObj = Content;
|
||||
|
@ -10,8 +10,8 @@ module.exports = {
|
||||
debug: false,
|
||||
session_secret: 'doracms_secret', // 务必修改
|
||||
auth_cookie_name: 'doracms',
|
||||
encrypt_key : 'dora',
|
||||
// 数据库配置
|
||||
COOKIE_SECRET: 'doramart.com',
|
||||
URL: 'mongodb://127.0.0.1:27017/doracms',
|
||||
DB: 'doracms',
|
||||
HOST: '',
|
||||
@ -58,8 +58,13 @@ module.exports = {
|
||||
// 本地缓存设置
|
||||
redis_host: '127.0.0.1',
|
||||
redis_port: 6379,
|
||||
redis_db: 0
|
||||
redis_db: 0,
|
||||
|
||||
// 邮件相关设置
|
||||
site_email : 'xx@163.com',
|
||||
site_email_psd : 'xxx',
|
||||
email_findPsd : 'findPsd',
|
||||
email_reg_active : 'reg_active'
|
||||
};
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ var ContentCategory = require("../ContentCategory");
|
||||
var ContentTags = require("../ContentTags");
|
||||
//广告对象
|
||||
var Ads = require("../Ads");
|
||||
var Settings = require("./settings");
|
||||
var settings = require("./settings");
|
||||
//数据库操作对象
|
||||
var DbOpt = require("../Dbopt");
|
||||
//时间格式化
|
||||
@ -29,44 +29,56 @@ var siteFunc = {
|
||||
if (cmsDescription) {
|
||||
discrip = cmsDescription;
|
||||
} else {
|
||||
discrip = Settings.CMSDISCRIPTION;
|
||||
discrip = settings.CMSDISCRIPTION;
|
||||
}
|
||||
|
||||
if (keyWords) {
|
||||
key = keyWords + ',' + Settings.SITEBASICKEYWORDS;
|
||||
key = keyWords + ',' + settings.SITEBASICKEYWORDS;
|
||||
} else {
|
||||
key = Settings.SITEKEYWORDS;
|
||||
key = settings.SITEKEYWORDS;
|
||||
}
|
||||
|
||||
return {
|
||||
title: title + " | " + Settings.SITETITLE,
|
||||
title: title + " | " + settings.SITETITLE,
|
||||
cmsDescription: discrip,
|
||||
keywords: key,
|
||||
siteIcp: Settings.SITEICP
|
||||
siteIcp: settings.SITEICP
|
||||
}
|
||||
},
|
||||
|
||||
getCategoryList : function(){
|
||||
return ContentCategory.find({'parentID': '0','state' : '1'},'name defaultUrl').sort({'sortId': 1}).find();
|
||||
setConfirmPassWordEmailTemp : function(name,token){
|
||||
|
||||
var html = '<p>您好:' + name + '</p>' +
|
||||
'<p>我们收到您在' + settings.SITETITLE + '的注册信息,请点击下面的链接来激活帐户:</p>' +
|
||||
'<a href="' + settings.SITEDOMAIN + '/users/reset_pass?key=' + token + '">重置密码链接</a>' +
|
||||
'<p>若您没有在<strong>' + settings.SITETITLE + '</strong>填写过注册信息,说明有人滥用了您的电子邮箱,请忽略或删除此邮件,我们对给您造成的打扰感到抱歉。</p>' +
|
||||
'<p><strong>' + settings.SITETITLE + ' </strong>谨上。</p>';
|
||||
|
||||
return html;
|
||||
|
||||
},
|
||||
|
||||
getHotItemListData : function(q){
|
||||
return Content.find(q,'stitle').sort({'clickNum': -1}).skip(0).limit(15);
|
||||
getCategoryList: function () {
|
||||
return ContentCategory.find({'parentID': '0', 'state': '1'}, 'name defaultUrl').sort({'sortId': 1}).find();
|
||||
},
|
||||
|
||||
getFriendLink : function(){
|
||||
return Ads.find({'category' : 'friendlink'});
|
||||
getHotItemListData: function (q) {
|
||||
return Content.find(q, 'stitle').sort({'clickNum': -1}).skip(0).limit(15);
|
||||
},
|
||||
|
||||
getFriendLink: function () {
|
||||
return Ads.find({'category': 'friendlink'});
|
||||
},
|
||||
|
||||
setDataForIndex: function (req, res, q, title) {
|
||||
var requireField = 'title date commentNum discription sImg';
|
||||
var documentList = DbOpt.getPaginationResult(Content, req, res, q , requireField);
|
||||
var documentList = DbOpt.getPaginationResult(Content, req, res, q, requireField);
|
||||
var tagsData = DbOpt.getDatasByParam(ContentTags, req, res, {});
|
||||
return {
|
||||
siteConfig: siteFunc.siteInfos("首页"),
|
||||
documentList: documentList.docs,
|
||||
hotItemListData: siteFunc.getHotItemListData({}),
|
||||
friendLinkData : siteFunc.getFriendLink(),
|
||||
friendLinkData: siteFunc.getFriendLink(),
|
||||
cateTypes: siteFunc.getCategoryList(),
|
||||
cateInfo: '',
|
||||
tagsData: tagsData,
|
||||
@ -79,7 +91,7 @@ var siteFunc = {
|
||||
|
||||
setDataForCate: function (req, res, dq, cq, cateInfo) {
|
||||
var requireField = 'title date commentNum discription sImg';
|
||||
var documentList = DbOpt.getPaginationResult(Content, req, res, dq , requireField);
|
||||
var documentList = DbOpt.getPaginationResult(Content, req, res, dq, requireField);
|
||||
var currentCateList = ContentCategory.find(cq).sort({'sortId': 1});
|
||||
var tagsData = DbOpt.getDatasByParam(ContentTags, req, res, {});
|
||||
return {
|
||||
@ -87,7 +99,7 @@ var siteFunc = {
|
||||
documentList: documentList.docs,
|
||||
currentCateList: currentCateList,
|
||||
hotItemListData: siteFunc.getHotItemListData(dq),
|
||||
friendLinkData : siteFunc.getFriendLink(),
|
||||
friendLinkData: siteFunc.getFriendLink(),
|
||||
tagsData: tagsData,
|
||||
cateInfo: cateInfo,
|
||||
cateTypes: siteFunc.getCategoryList(),
|
||||
@ -106,7 +118,7 @@ var siteFunc = {
|
||||
cateTypes: siteFunc.getCategoryList(),
|
||||
currentCateList: currentCateList,
|
||||
hotItemListData: siteFunc.getHotItemListData({}),
|
||||
friendLinkData : siteFunc.getFriendLink(),
|
||||
friendLinkData: siteFunc.getFriendLink(),
|
||||
tagsData: tagsData,
|
||||
documentInfo: docs,
|
||||
pageType: 'detail',
|
||||
@ -118,7 +130,7 @@ var siteFunc = {
|
||||
setDataForSearch: function (req, res, q, searchKey) {
|
||||
req.query.searchKey = searchKey;
|
||||
var requireField = 'title date commentNum discription sImg';
|
||||
var documentList = DbOpt.getPaginationResult(Content, req, res, q , requireField);
|
||||
var documentList = DbOpt.getPaginationResult(Content, req, res, q, requireField);
|
||||
return {
|
||||
siteConfig: siteFunc.siteInfos("文档搜索"),
|
||||
documentList: documentList.docs,
|
||||
@ -142,15 +154,28 @@ var siteFunc = {
|
||||
}
|
||||
},
|
||||
|
||||
setDataForUser: function (req, res, title) {
|
||||
setDataForUser: function (req, res, title ,tokenId) {
|
||||
return {
|
||||
siteConfig: siteFunc.siteInfos(title),
|
||||
cateTypes: siteFunc.getCategoryList(),
|
||||
userInfo: req.session.user,
|
||||
tokenId : tokenId,
|
||||
layout: 'web/public/defaultTemp'
|
||||
}
|
||||
},
|
||||
|
||||
setDataForInfo : function(infoType,infoContent){
|
||||
|
||||
return {
|
||||
siteConfig: siteFunc.siteInfos('操作提示'),
|
||||
cateTypes: siteFunc.getCategoryList(),
|
||||
infoType : infoType,
|
||||
infoContent : infoContent,
|
||||
layout: 'web/public/defaultTemp'
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
setDataForSiteMap: function (req, res) {
|
||||
|
||||
var root_path = 'http://www.html-js.cn/';
|
||||
@ -206,7 +231,6 @@ var siteFunc = {
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
module.exports = siteFunc;
|
83
public/javascripts/dora.public.js
Normal file
83
public/javascripts/dora.public.js
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
前后台公用js*/
|
||||
|
||||
$(function(){
|
||||
//用户注销
|
||||
$('#userLoginOut').click(function () {
|
||||
loginOut();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function initPagination($scope,$http,localUrl,param){
|
||||
|
||||
// 定义翻页动作
|
||||
$scope.loadPage = function(page){
|
||||
$scope.currentPage = page;
|
||||
window.location.href = localUrl + "—"+$scope.currentPage+".html"+param;
|
||||
};
|
||||
|
||||
$scope.nextPage = function () {
|
||||
if ($scope.currentPage < $scope.totalPage) {
|
||||
$scope.currentPage++;
|
||||
window.location.href = localUrl + "—"+$scope.currentPage+".html"+param;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.prevPage = function () {
|
||||
if ($scope.currentPage > 1) {
|
||||
$scope.currentPage--;
|
||||
window.location.href = localUrl + "—"+$scope.currentPage+".html"+param;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if($scope.currentPage){
|
||||
if ($scope.currentPage > 1 && $scope.currentPage < $scope.totalPage) {
|
||||
$scope.pages = [
|
||||
$scope.currentPage - 1,
|
||||
$scope.currentPage,
|
||||
$scope.currentPage + 1
|
||||
];
|
||||
}
|
||||
else if ($scope.currentPage == 1 && $scope.totalPage == 1) {
|
||||
$scope.pages = [
|
||||
$scope.currentPage
|
||||
|
||||
];
|
||||
}
|
||||
else if ($scope.currentPage == 1 && $scope.totalPage > 1) {
|
||||
$scope.pages = [
|
||||
$scope.currentPage,
|
||||
$scope.currentPage + 1
|
||||
];
|
||||
} else if ($scope.currentPage == $scope.totalPage && $scope.totalPage > 1) {
|
||||
$scope.pages = [
|
||||
$scope.currentPage - 1,
|
||||
$scope.currentPage
|
||||
];
|
||||
}
|
||||
}else{
|
||||
console.log("获取分页信息失败")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function loginOut(){
|
||||
$.ajax({
|
||||
url: "/users/logout",
|
||||
method: "GET",
|
||||
success: function (result) {
|
||||
if (result === "success") {
|
||||
window.location = "/"
|
||||
} else {
|
||||
alert("未知异常,请稍后重试");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
@ -156,7 +156,7 @@ a:hover {
|
||||
}
|
||||
|
||||
/*热门文档*/
|
||||
.hotNewsList, .searchBoard, .leftNav, .tagsList, .cateList, .friendLink {
|
||||
.hotNewsList, .searchBoard, .leftNav, .tagsList, .cateList, .friendLink ,.reSetPsdBoard {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ a:hover {
|
||||
|
||||
|
||||
/*用户登录*/
|
||||
.loginBoard h3, .regBoard h3 {
|
||||
.loginBoard h3, .regBoard h3 , .conformBoard h3, .reSetPsdBoard h3,.noticeBoard h3 {
|
||||
color: #6e7173;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
106
routes/admin.js
106
routes/admin.js
@ -27,9 +27,9 @@ var Ads = require("../models/Ads");
|
||||
//数据校验
|
||||
var validator = require('validator');
|
||||
//系统操作
|
||||
var System = require("../models/System");
|
||||
var system = require("../util/system");
|
||||
//站点配置
|
||||
var Settings = require("../models/db/settings");
|
||||
var settings = require("../models/db/settings");
|
||||
var adminFunc = require("../models/db/adminFunc");
|
||||
//加密类
|
||||
var crypto = require("crypto");
|
||||
@ -67,7 +67,7 @@ function checkAdminPower(req,key,callBack) {
|
||||
|
||||
//管理员登录页面
|
||||
router.get('/', function(req, res, next) {
|
||||
res.render('manage/adminLogin', { title: Settings.SITETITLE , description : 'DoraCMS后台管理登录'});
|
||||
res.render('manage/adminLogin', { title: settings.SITETITLE , description : 'DoraCMS后台管理登录'});
|
||||
});
|
||||
|
||||
// 管理员登录提交请求
|
||||
@ -75,7 +75,7 @@ router.post('/doLogin', function(req, res, next) {
|
||||
var username = req.body.username;
|
||||
var password = req.body.password;
|
||||
|
||||
var newPsd = DbOpt.encrypt(password,"dora");
|
||||
var newPsd = DbOpt.encrypt(password,settings.encrypt_key);
|
||||
AdminUser.findOne({username:username,password:newPsd},function(err,user){
|
||||
if(user){
|
||||
req.session.adminlogined = true;
|
||||
@ -98,7 +98,7 @@ router.get('/logout', function(req, res, next) {
|
||||
|
||||
//后台用户起始页
|
||||
router.get('/manage', function(req, res, next) {
|
||||
res.render('manage/main', adminFunc.setPageInfo(req,res,Settings.SYSTEMMANAGE));
|
||||
res.render('manage/main', adminFunc.setPageInfo(req,res,settings.SYSTEMMANAGE));
|
||||
});
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ router.post('/manage/:defaultUrl/modify',function(req,res,next){
|
||||
var targetObj = adminFunc.getTargetObj(currentPage);
|
||||
if(targetObj == AdminUser || targetObj == User){
|
||||
var password = req.body.password;
|
||||
var newPsd = DbOpt.encrypt(password,"dora");
|
||||
var newPsd = DbOpt.encrypt(password,settings.encrypt_key);
|
||||
req.body.password = newPsd;
|
||||
}
|
||||
DbOpt.updateOneByID(targetObj,req, res,"find one obj success")
|
||||
@ -222,10 +222,10 @@ function removeMessage(req,res){
|
||||
//系统用户管理(list)
|
||||
router.get('/manage/adminUsersList', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.ADMINUSERLIST,function(state){
|
||||
checkAdminPower(req,settings.ADMINUSERLIST,function(state){
|
||||
|
||||
if(state){
|
||||
res.render('manage/adminUsersList', adminFunc.setPageInfo(req,res,Settings.ADMINUSERLIST));
|
||||
res.render('manage/adminUsersList', adminFunc.setPageInfo(req,res,settings.ADMINUSERLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -249,7 +249,7 @@ function addOneAdminUser(req,res){
|
||||
res.end(errors)
|
||||
}else{
|
||||
// 密码加密
|
||||
req.body.password = DbOpt.encrypt(req.body.password,"dora");
|
||||
req.body.password = DbOpt.encrypt(req.body.password,settings.encrypt_key);
|
||||
DbOpt.addOne(AdminUser,req, res,"add new adminUser");
|
||||
}
|
||||
}
|
||||
@ -266,10 +266,10 @@ function addOneAdminUser(req,res){
|
||||
//系统用户组管理(list)
|
||||
router.get('/manage/adminGroupList', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.ADMINGROUPLIST,function(state){
|
||||
checkAdminPower(req,settings.ADMINGROUPLIST,function(state){
|
||||
|
||||
if(state){
|
||||
res.render('manage/adminGroup', adminFunc.setPageInfo(req,res,Settings.ADMINGROUPLIST));
|
||||
res.render('manage/adminGroup', adminFunc.setPageInfo(req,res,settings.ADMINGROUPLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -296,9 +296,9 @@ router.get('/manage/adminGroupList/list', function(req, res, next) {
|
||||
//文件管理界面(list)
|
||||
router.get('/manage/filesList', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.FILESLIST,function(state){
|
||||
checkAdminPower(req,settings.FILESLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/filesList', adminFunc.setPageInfo(req,res,Settings.FILESLIST));
|
||||
res.render('manage/filesList', adminFunc.setPageInfo(req,res,settings.FILESLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -311,14 +311,14 @@ router.get('/manage/filesList/list', function(req, res, next) {
|
||||
var params = url.parse(req.url,true);
|
||||
var path = params.query.filePath;
|
||||
if(!path){
|
||||
path = Settings.UPDATEFOLDER;
|
||||
path = settings.UPDATEFOLDER;
|
||||
}
|
||||
|
||||
var filePath = System.scanFolder(path);
|
||||
var filePath = system.scanFolder(path);
|
||||
// 对返回结果做初步排序
|
||||
filePath.sort(function(a,b){return a.type == "folder" || b.type == "folder"});
|
||||
return res.json({
|
||||
rootPath : Settings.UPDATEFOLDER,
|
||||
rootPath : settings.UPDATEFOLDER,
|
||||
pathsInfo : filePath
|
||||
});
|
||||
|
||||
@ -330,7 +330,7 @@ router.get('/manage/filesList/fileDel', function(req, res, next) {
|
||||
var params = url.parse(req.url,true);
|
||||
var path = params.query.filePath;
|
||||
if(path){
|
||||
System.deleteFolder(req, res, path);
|
||||
system.deleteFolder(req, res, path);
|
||||
}
|
||||
});
|
||||
|
||||
@ -339,7 +339,7 @@ router.post('/manage/filesList/fileReName', function(req, res, next) {
|
||||
var newPath = req.body.newPath;
|
||||
var path = req.body.path;
|
||||
if(path && newPath){
|
||||
System.reNameFile(req,res,path,newPath);
|
||||
system.reNameFile(req,res,path,newPath);
|
||||
}
|
||||
});
|
||||
|
||||
@ -349,7 +349,7 @@ router.get('/manage/filesList/getFileInfo', function(req, res, next) {
|
||||
var params = url.parse(req.url,true);
|
||||
var path = params.query.filePath;
|
||||
if(path){
|
||||
System.readFile(req,res,path);
|
||||
system.readFile(req,res,path);
|
||||
}
|
||||
});
|
||||
|
||||
@ -359,7 +359,7 @@ router.post('/manage/filesList/updateFileInfo', function(req, res, next) {
|
||||
var fileContent = req.body.code;
|
||||
var path = req.body.path;
|
||||
if(path){
|
||||
System.writeFile(req,res,path,fileContent);
|
||||
system.writeFile(req,res,path,fileContent);
|
||||
}
|
||||
});
|
||||
|
||||
@ -370,9 +370,9 @@ router.post('/manage/filesList/updateFileInfo', function(req, res, next) {
|
||||
|
||||
router.get('/manage/dataManage/m/backUpData', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.DATAMANAGE,function(state){
|
||||
checkAdminPower(req,settings.DATAMANAGE,function(state){
|
||||
if(state){
|
||||
res.render('manage/backUpData', adminFunc.setPageInfo(req,res,Settings.DATAMANAGE));
|
||||
res.render('manage/backUpData', adminFunc.setPageInfo(req,res,settings.DATAMANAGE));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -382,7 +382,7 @@ router.get('/manage/dataManage/m/backUpData', function(req, res, next) {
|
||||
|
||||
//备份数据库执行
|
||||
router.get('/manage/backupDataManage/backUp', function(req, res, next) {
|
||||
System.backUpData(res,req);
|
||||
system.backUpData(res,req);
|
||||
});
|
||||
|
||||
|
||||
@ -396,7 +396,7 @@ router.get('/manage/backupDataManage/del', function(req, res, next) {
|
||||
res.end(err);
|
||||
}else{
|
||||
if(forderPath){
|
||||
System.deleteFolder(req, res,forderPath);
|
||||
system.deleteFolder(req, res,forderPath);
|
||||
}else{
|
||||
res.end("error");
|
||||
}
|
||||
@ -414,9 +414,9 @@ router.get('/manage/backupDataManage/del', function(req, res, next) {
|
||||
router.get('/manage/contentList', function(req, res, next) {
|
||||
|
||||
|
||||
checkAdminPower(req,Settings.CONTENTLIST,function(state){
|
||||
checkAdminPower(req,settings.CONTENTLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/contentList', adminFunc.setPageInfo(req,res,Settings.CONTENTLIST));
|
||||
res.render('manage/contentList', adminFunc.setPageInfo(req,res,settings.CONTENTLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -432,7 +432,7 @@ router.get('/manage/content/add/:key', function(req, res, next) {
|
||||
|
||||
var contentType = req.params.key;
|
||||
var targetPath;
|
||||
checkAdminPower(req,Settings.CONTENTLIST,function(state){
|
||||
checkAdminPower(req,settings.CONTENTLIST,function(state){
|
||||
|
||||
if(contentType == "film"){
|
||||
targetPath = 'manage/addProduct';
|
||||
@ -443,7 +443,7 @@ router.get('/manage/content/add/:key', function(req, res, next) {
|
||||
}
|
||||
|
||||
if(state){
|
||||
res.render(targetPath, adminFunc.setPageInfo(req,res,Settings.CONTENTLIST));
|
||||
res.render(targetPath, adminFunc.setPageInfo(req,res,settings.CONTENTLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -456,7 +456,7 @@ router.get('/manage/content/add/:key', function(req, res, next) {
|
||||
router.get('/manage/content/edit/:type/:content', function(req, res, next) {
|
||||
var contentType = req.params.type;
|
||||
var targetPath;
|
||||
checkAdminPower(req,Settings.CONTENTLIST,function(state){
|
||||
checkAdminPower(req,settings.CONTENTLIST,function(state){
|
||||
|
||||
if(contentType == "film"){
|
||||
targetPath = 'manage/addProduct';
|
||||
@ -466,7 +466,7 @@ router.get('/manage/content/edit/:type/:content', function(req, res, next) {
|
||||
targetPath = 'manage/addContent';
|
||||
}
|
||||
if(state){
|
||||
res.render(targetPath, adminFunc.setPageInfo(req,res,Settings.CONTENTLIST));
|
||||
res.render(targetPath, adminFunc.setPageInfo(req,res,settings.CONTENTLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -492,9 +492,9 @@ router.get('/manage/ContentList/topContent', function(req, res, next) {
|
||||
//文档类别列表页面
|
||||
router.get('/manage/contentCategorys', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.CONTENTCATEGORYS,function(state){
|
||||
checkAdminPower(req,settings.CONTENTCATEGORYS,function(state){
|
||||
if(state){
|
||||
res.render('manage/contentCategorys', adminFunc.setPageInfo(req,res,Settings.CONTENTCATEGORYS));
|
||||
res.render('manage/contentCategorys', adminFunc.setPageInfo(req,res,settings.CONTENTCATEGORYS));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -539,9 +539,9 @@ function addOneCategory(req,res){
|
||||
//文档标签管理(list)
|
||||
router.get('/manage/contentTags', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.CONTENTTAGS,function(state){
|
||||
checkAdminPower(req,settings.CONTENTTAGS,function(state){
|
||||
if(state){
|
||||
res.render('manage/contentTags', adminFunc.setPageInfo(req,res,Settings.CONTENTTAGS));
|
||||
res.render('manage/contentTags', adminFunc.setPageInfo(req,res,settings.CONTENTTAGS));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -581,9 +581,9 @@ function addOneContentTags(req,res){
|
||||
//文档模板管理(list)
|
||||
router.get('/manage/contentTemps', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.CONTENTTEMPS,function(state){
|
||||
checkAdminPower(req,settings.CONTENTTEMPS,function(state){
|
||||
if(state){
|
||||
res.render('manage/contentTemps', adminFunc.setPageInfo(req,res,Settings.CONTENTTEMPS));
|
||||
res.render('manage/contentTemps', adminFunc.setPageInfo(req,res,settings.CONTENTTEMPS));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -620,7 +620,7 @@ function addOneContentTemps(req,res){
|
||||
//读取模板文件夹信息
|
||||
router.get('/manage/contentTemps/forderList', function(req, res, next) {
|
||||
|
||||
var filePath = System.scanJustFolder(Settings.TEMPSFOLDER);
|
||||
var filePath = system.scanJustFolder(settings.TEMPSFOLDER);
|
||||
// 对返回结果做初步排序
|
||||
filePath.sort(function(a,b){return a.type == "folder" || b.type == "folder"});
|
||||
|
||||
@ -638,9 +638,9 @@ router.get('/manage/contentTemps/forderList', function(req, res, next) {
|
||||
//文档留言管理(list)
|
||||
router.get('/manage/contentMsgs', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.MESSAGEMANAGE,function(state){
|
||||
checkAdminPower(req,settings.MESSAGEMANAGE,function(state){
|
||||
if(state){
|
||||
res.render('manage/messageList', adminFunc.setPageInfo(req,res,Settings.MESSAGEMANAGE));
|
||||
res.render('manage/messageList', adminFunc.setPageInfo(req,res,settings.MESSAGEMANAGE));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -657,9 +657,9 @@ router.get('/manage/contentMsgs', function(req, res, next) {
|
||||
//注册用户管理(list)
|
||||
router.get('/manage/regUsersList', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.REGUSERSLIST,function(state){
|
||||
checkAdminPower(req,settings.REGUSERSLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/regUsersList', adminFunc.setPageInfo(req,res,Settings.REGUSERSLIST));
|
||||
res.render('manage/regUsersList', adminFunc.setPageInfo(req,res,settings.REGUSERSLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -673,9 +673,9 @@ router.get('/manage/regUsersList', function(req, res, next) {
|
||||
//邮件模板列表页面
|
||||
router.get('/manage/emailTempList', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.EMAILTEMPLIST,function(state){
|
||||
checkAdminPower(req,settings.EMAILTEMPLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/emailTempList', adminFunc.setPageInfo(req,res,Settings.EMAILTEMPLIST));
|
||||
res.render('manage/emailTempList', adminFunc.setPageInfo(req,res,settings.EMAILTEMPLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -689,9 +689,9 @@ router.get('/manage/emailTempList', function(req, res, next) {
|
||||
//邮件模板添加页面
|
||||
router.get('/manage/emailTemp/add', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.EMAILTEMPLIST,function(state){
|
||||
checkAdminPower(req,settings.EMAILTEMPLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/addEmailTemp', adminFunc.setPageInfo(req,res,Settings.EMAILTEMPLIST));
|
||||
res.render('manage/addEmailTemp', adminFunc.setPageInfo(req,res,settings.EMAILTEMPLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -703,9 +703,9 @@ router.get('/manage/emailTemp/add', function(req, res, next) {
|
||||
//邮件模板编辑页面
|
||||
router.get('/manage/emailTemp/edit/:content', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.EMAILTEMPLIST,function(state){
|
||||
checkAdminPower(req,settings.EMAILTEMPLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/addEmailTemp', adminFunc.setPageInfo(req,res,Settings.EMAILTEMPLIST));
|
||||
res.render('manage/addEmailTemp', adminFunc.setPageInfo(req,res,settings.EMAILTEMPLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -720,9 +720,9 @@ router.get('/manage/emailTemp/edit/:content', function(req, res, next) {
|
||||
//广告管理列表页面
|
||||
router.get('/manage/adsList', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.ADSLIST,function(state){
|
||||
checkAdminPower(req,settings.ADSLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/adsList', adminFunc.setPageInfo(req,res,Settings.ADSLIST));
|
||||
res.render('manage/adsList', adminFunc.setPageInfo(req,res,settings.ADSLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -736,9 +736,9 @@ router.get('/manage/adsList', function(req, res, next) {
|
||||
//广告添加页面
|
||||
router.get('/manage/ads/add', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.ADSLIST,function(state){
|
||||
checkAdminPower(req,settings.ADSLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/addAds', adminFunc.setPageInfo(req,res,Settings.ADSLIST));
|
||||
res.render('manage/addAds', adminFunc.setPageInfo(req,res,settings.ADSLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
@ -750,9 +750,9 @@ router.get('/manage/ads/add', function(req, res, next) {
|
||||
//广告编辑页面
|
||||
router.get('/manage/ads/edit/:content', function(req, res, next) {
|
||||
|
||||
checkAdminPower(req,Settings.ADSLIST,function(state){
|
||||
checkAdminPower(req,settings.ADSLIST,function(state){
|
||||
if(state){
|
||||
res.render('manage/addAds', adminFunc.setPageInfo(req,res,Settings.ADSLIST));
|
||||
res.render('manage/addAds', adminFunc.setPageInfo(req,res,settings.ADSLIST));
|
||||
}else{
|
||||
res.redirect("/admin/manage");
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ var Message = require("../models/Message");
|
||||
//广告对象
|
||||
var Ads = require("../models/Ads");
|
||||
//站点配置
|
||||
var Settings = require("../models/db/settings");
|
||||
var settings = require("../models/db/settings");
|
||||
var siteFunc = require("../models/db/siteFunc");
|
||||
|
||||
var url = require('url');
|
||||
|
@ -12,7 +12,7 @@ var shortid = require('shortid');
|
||||
//时间格式化
|
||||
var moment = require('moment');
|
||||
//站点配置
|
||||
var Settings = require("../models/db/settings");
|
||||
var settings = require("../models/db/settings");
|
||||
var siteFunc = require("../models/db/siteFunc");
|
||||
var url = require('url');
|
||||
|
||||
|
@ -8,7 +8,7 @@ var router = express.Router();
|
||||
var formidable = require('formidable'),
|
||||
util = require('util'),fs=require('fs');
|
||||
//系统相关操作
|
||||
var System = require("../models/System");
|
||||
var system = require("../util/system");
|
||||
var gm = require('gm');
|
||||
var url = require('url');
|
||||
/* GET users listing. */
|
||||
@ -114,7 +114,7 @@ router.post('/upload', function(req, res, next) {
|
||||
//邮件发送
|
||||
router.post('/sendEmail', function(req, res, next) {
|
||||
console.log("---------begin to sent email-------------");
|
||||
System.sendEmail();
|
||||
system.sendEmail();
|
||||
});
|
||||
|
||||
module.exports = router;
|
130
routes/users.js
130
routes/users.js
@ -16,11 +16,11 @@ var DbOpt = require("../models/Dbopt");
|
||||
//加密类
|
||||
var crypto = require("crypto");
|
||||
//系统相关操作
|
||||
var System = require("../models/System");
|
||||
var system = require("../util/system");
|
||||
//时间格式化
|
||||
var moment = require('moment');
|
||||
//站点配置
|
||||
var Settings = require("../models/db/settings");
|
||||
var settings = require("../models/db/settings");
|
||||
var siteFunc = require("../models/db/siteFunc");
|
||||
|
||||
//数据校验
|
||||
@ -54,7 +54,7 @@ router.get('/login', function(req, res, next) {
|
||||
res.render('web/index', siteFunc.setDataForIndex(req, res, {'type': 'content'}, '首页'))
|
||||
}else{
|
||||
req.session._loginReferer = req.headers.referer;
|
||||
res.render('web/users/userLogin', siteFunc.setDataForUser(req, res, '用户登录'))
|
||||
res.render('web/users/userLogin', siteFunc.setDataForUser(req, res, '用户登录'));
|
||||
}
|
||||
|
||||
});
|
||||
@ -64,7 +64,7 @@ router.post('/doLogin', function(req, res, next) {
|
||||
var email = req.body.email;
|
||||
var password = req.body.password;
|
||||
|
||||
var newPsd = DbOpt.encrypt(password,"dora");
|
||||
var newPsd = DbOpt.encrypt(password,settings.encrypt_key);
|
||||
User.findOne({email:email,password:newPsd},function(err,user){
|
||||
if(user){
|
||||
// 将cookie存入缓存
|
||||
@ -118,7 +118,7 @@ router.post('/doReg', function(req, res, next) {
|
||||
}
|
||||
else{
|
||||
// 数据加密
|
||||
var newPsd = DbOpt.encrypt(password,"dora");
|
||||
var newPsd = DbOpt.encrypt(password,settings.encrypt_key);
|
||||
req.body.password = newPsd;
|
||||
DbOpt.addOne(User,req, res,"add a new user")
|
||||
}
|
||||
@ -127,22 +127,102 @@ router.post('/doReg', function(req, res, next) {
|
||||
|
||||
});
|
||||
|
||||
//忘记密码页面
|
||||
router.get('/lostPassword', function(req, res, next) {
|
||||
|
||||
res.render('web/users/userConfirmEmail', siteFunc.setDataForUser(req, res, '确认邮箱'))
|
||||
|
||||
});
|
||||
|
||||
|
||||
//提交验证邮箱
|
||||
router.post('/sentConfirmEmail',function(req, res, next){
|
||||
|
||||
var targetEmail = req.body.email;
|
||||
// 获取当前发送邮件的时间
|
||||
var retrieveTime = new Date().getTime();
|
||||
User.findOne({'email' : targetEmail},function(err,user){
|
||||
if(err){
|
||||
res.end(err)
|
||||
}else{
|
||||
if(user && user._id){
|
||||
|
||||
user.retrieve_time = retrieveTime;
|
||||
user.save(function(err){
|
||||
if(err){
|
||||
return next(err);
|
||||
}else{
|
||||
system.sendEmail(settings.email_findPsd,user,function(){
|
||||
console.log('-------邮件发送成功-------');
|
||||
res.end("success");
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
}else{
|
||||
res.end('错误:未能通过电子邮件地址找到用户。');
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
//点击找回密码链接跳转页面
|
||||
router.get('/reset_pass',function(req,res){
|
||||
var params = url.parse(req.url,true);
|
||||
var tokenId = params.query.key;
|
||||
var newLink = DbOpt.decrypt(tokenId,settings.encrypt_key);
|
||||
var keyArr = newLink.split('$');
|
||||
User.findOne({'email' : keyArr[1]},function(err,user){
|
||||
|
||||
if(err){
|
||||
res.end(err);
|
||||
}else{
|
||||
if(user && user._id){
|
||||
if(user.password == keyArr[0] && keyArr[2] == settings.session_secret){
|
||||
// 校验链接是否过期
|
||||
var now = new Date().getTime();
|
||||
var oneDay = 1000 * 60 * 60 * 24;
|
||||
if (!user.retrieve_time || now - user.retrieve_time > oneDay) {
|
||||
// res.status(403);
|
||||
res.render('web/users/userNotice', siteFunc.setDataForInfo('warning','链接超时,密码无法重置。'));
|
||||
}
|
||||
res.render('web/users/userResetPsd', siteFunc.setDataForUser(req, res, '重设密码',tokenId))
|
||||
}else{
|
||||
res.render('web/users/userNotice', siteFunc.setDataForInfo('warning','信息有误,密码无法重置。'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
router.post('/updateNewPsd',function(req,res){
|
||||
|
||||
var keyArr = DbOpt.getKeyArrByTokenId(req.body.tokenId);
|
||||
User.findOne({'email' : keyArr[1]},function(err,user){
|
||||
if(err){
|
||||
res.end(err);
|
||||
}else{
|
||||
if(user.password == keyArr[0] && keyArr[2] == settings.session_secret){
|
||||
|
||||
user.password = DbOpt.encrypt(req.body.password,settings.encrypt_key);
|
||||
user.save(function(err){
|
||||
if(err){
|
||||
res.end(err)
|
||||
}else{
|
||||
user.retrieve_time = null;
|
||||
res.end('success');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
// 用户主页
|
||||
//router.get('/info', function(req, res, next) {
|
||||
// if(isLogined(req)){
|
||||
// res.render('web/users/user', {
|
||||
// siteConfig : siteFunc.siteInfos("用户主页") ,
|
||||
// cateTypes : ContentCategory.find({'parentID' : '0'}).sort({'sortId': 1}),
|
||||
// userInfo : req.session.userInfo,
|
||||
// layout: 'web/temp/user' });
|
||||
// }
|
||||
// else{
|
||||
// res.render('web/do404', { siteConfig : siteFunc.siteInfos("操作失败") , layout: 'web/temp/errorTemp' });
|
||||
// }
|
||||
//
|
||||
//});
|
||||
|
||||
//用户中心
|
||||
router.get('/userCenter', function(req, res, next) {
|
||||
@ -170,7 +250,7 @@ router.get('/setUserPsd', function(req, res, next) {
|
||||
// 用户退出
|
||||
router.get('/logout', function(req, res, next) {
|
||||
req.session.destroy();
|
||||
res.clearCookie(Settings.auth_cookie_name, { path: '/' });
|
||||
res.clearCookie(settings.auth_cookie_name, { path: '/' });
|
||||
res.end("success");
|
||||
});
|
||||
|
||||
@ -186,7 +266,7 @@ router.get('/userInfo', function(req, res, next) {
|
||||
}else{
|
||||
// 针对有密码的记录,需要解密后再返回
|
||||
if(result && result.password){
|
||||
var decipher = crypto.createDecipher("bf","dora");
|
||||
var decipher = crypto.createDecipher("bf",settings.encrypt_key);
|
||||
var oldPsd = "";
|
||||
oldPsd += decipher.update(result.password,"hex","utf8");
|
||||
oldPsd += decipher.final("utf8");
|
||||
@ -202,7 +282,7 @@ router.get('/userInfo', function(req, res, next) {
|
||||
//修改用户信息
|
||||
router.post('/userInfo/modify', function(req, res, next) {
|
||||
var password = req.body.password;
|
||||
var newPsd = DbOpt.encrypt(password,"dora");
|
||||
var newPsd = DbOpt.encrypt(password,settings.encrypt_key);
|
||||
req.body.password = newPsd;
|
||||
DbOpt.updateOneByID(User,req, res,"modify regUser");
|
||||
});
|
||||
@ -215,8 +295,8 @@ router.post('/resetMyPsd', function(req, res, next) {
|
||||
var oldPassword = req.body.oldPassword;
|
||||
var userPsd = req.body.password;
|
||||
// 密码加密
|
||||
var oldPsd = DbOpt.encrypt(oldPassword,"dora");
|
||||
var newPsd = DbOpt.encrypt(userPsd,"dora");
|
||||
var oldPsd = DbOpt.encrypt(oldPassword,settings.encrypt_key);
|
||||
var newPsd = DbOpt.encrypt(userPsd,settings.encrypt_key);
|
||||
User.findOne({_id:userId},function(err,user){
|
||||
if(user){
|
||||
// 验证是否是本人操作,提高安全性
|
||||
@ -224,7 +304,7 @@ router.post('/resetMyPsd', function(req, res, next) {
|
||||
// 更新密码
|
||||
User.update({_id:userId}, {password : newPsd}, function (err,result) {
|
||||
if(err){
|
||||
|
||||
res.end(err);
|
||||
}else{
|
||||
res.end("success");
|
||||
}
|
||||
|
@ -14,63 +14,57 @@ var DataOptionLog = require("../models/DataOptionLog");
|
||||
//时间格式化
|
||||
var moment = require('moment');
|
||||
//站点配置
|
||||
var Settings = require("../models/db/settings");
|
||||
var settings = require("../models/db/settings");
|
||||
var siteFunc = require("../models/db/siteFunc");
|
||||
//文件压缩
|
||||
var fs = require('fs');
|
||||
var child = require('child_process');
|
||||
var archiver = require('archiver');
|
||||
var System = {
|
||||
var system = {
|
||||
|
||||
sendEmail : function(key,user){
|
||||
sendEmail : function(key,user,callBack){
|
||||
|
||||
var emailTitle = "Hello";
|
||||
var emailSubject = "Hello";
|
||||
var emailContent = "Hello";
|
||||
var emailLink = "";
|
||||
EmailTemp.findOne({type:key},function(err,temp){
|
||||
if(temp){
|
||||
// 设置邮件模板相关参数
|
||||
emailTitle = temp.title;
|
||||
emailSubject = temp.subject;
|
||||
emailContent = temp.comments;
|
||||
// 根据用户名和邮箱生成加密链接
|
||||
var oldlink = user.userName + user.email;
|
||||
var newLink = DbOpt.encrypt(oldlink,"dora");
|
||||
emailLink = user._id+"/"+newLink;
|
||||
|
||||
var ec1 = emailContent.replace("euserName",user.userName);
|
||||
var ec2 = ec1.replace("elink",emailLink);
|
||||
var oldLink = user.password +'$'+ user.email +'$'+ settings.session_secret;
|
||||
console.log('-------before send pds------'+user.password)
|
||||
var newLink = DbOpt.encrypt(oldLink,settings.encrypt_key);
|
||||
var tokenLink = newLink;
|
||||
|
||||
if(key == settings.email_findPsd){
|
||||
emailSubject = emailTitle = '通过激活链接找回密码';
|
||||
emailContent = siteFunc.setConfirmPassWordEmailTemp(user.userName,tokenLink);
|
||||
}
|
||||
|
||||
// 发送邮件
|
||||
var transporter = nodemailer.createTransport({
|
||||
service: '163',
|
||||
auth: {
|
||||
user: 'doramart@163.com',
|
||||
pass: 'yoooyu520'
|
||||
}
|
||||
});
|
||||
var transporter = nodemailer.createTransport({
|
||||
|
||||
var mailOptions = {
|
||||
from: 'doramart@163.com', // sender address
|
||||
to: user.email, // list of receivers
|
||||
subject: emailSubject, // Subject line
|
||||
text: emailTitle, // plaintext body
|
||||
html: ec2 // html body
|
||||
};
|
||||
service: '163',
|
||||
auth: {
|
||||
user: settings.site_email,
|
||||
pass: settings.site_email_psd
|
||||
}
|
||||
|
||||
transporter.sendMail(mailOptions, function(error, info){
|
||||
if(error){
|
||||
console.log(error);
|
||||
}else{
|
||||
console.log('Message sent: ' + info.response);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var mailOptions = {
|
||||
from: settings.site_email, // sender address
|
||||
to: user.email, // list of receivers
|
||||
subject: emailSubject, // Subject line
|
||||
text: emailTitle, // plaintext body
|
||||
html: emailContent // html body
|
||||
};
|
||||
|
||||
transporter.sendMail(mailOptions, function(error, info){
|
||||
if(error){
|
||||
console.log('邮件发送失败:'+error);
|
||||
}else{
|
||||
console.log('Message sent: ' + info.response);
|
||||
callBack();
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("邮件模板查询失败,无法正常发送");
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
@ -245,13 +239,13 @@ var System = {
|
||||
var date = new Date();
|
||||
// var ms = Date.parse(date);
|
||||
var ms = moment(date).format('YYYYMMDDHHmmss').toString();
|
||||
var dataPath = Settings.DATABACKFORDER + ms;
|
||||
var dataPath = settings.DATABACKFORDER + ms;
|
||||
// var cmdstr = 'mongodump -o "'+dataPath+'"';
|
||||
var cmdstr = 'mongodump -u '+Settings.USERNAME+' -p '+Settings.PASSWORD+' -d '+Settings.DB+' -o "'+dataPath+'"';
|
||||
var cmdstr = 'mongodump -u '+settings.USERNAME+' -p '+settings.PASSWORD+' -d '+settings.DB+' -o "'+dataPath+'"';
|
||||
|
||||
var batPath = Settings.DATAOPERATION + '/backupData.bat';
|
||||
if(!fs.existsSync(Settings.DATABACKFORDER)){
|
||||
fs.mkdirSync(Settings.DATABACKFORDER);
|
||||
var batPath = settings.DATAOPERATION + '/backupData.bat';
|
||||
if(!fs.existsSync(settings.DATABACKFORDER)){
|
||||
fs.mkdirSync(settings.DATABACKFORDER);
|
||||
}
|
||||
if (fs.existsSync(dataPath)) {
|
||||
|
||||
@ -277,7 +271,7 @@ var System = {
|
||||
}else{
|
||||
console.log('备份成功');
|
||||
// 生成压缩文件
|
||||
var output = fs.createWriteStream(Settings.DATABACKFORDER + ms +'.zip');
|
||||
var output = fs.createWriteStream(settings.DATABACKFORDER + ms +'.zip');
|
||||
var archive = archiver('zip');
|
||||
|
||||
archive.on('error', function(err){
|
||||
@ -314,8 +308,8 @@ var System = {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports = System;
|
||||
module.exports = system;
|
@ -143,7 +143,7 @@ Contact: cms@doramart.com
|
||||
<ul class="treeview-menu">
|
||||
<li cid="sysTemManage_0_1"><a href="/admin/manage/adminUsersList"><i class="fa fa-user"></i> 系统用户管理</a></li>
|
||||
<li cid="sysTemManage_0_2"><a href="/admin/manage/adminGroupList"><i class="fa fa-group"></i> 用户组设定</a></li>
|
||||
<li cid="sysTemManage_0_3"><a href="/admin/manage/emailTempList"><i class="fa fa-envelope"></i> 邮件模板</a></li>
|
||||
<li cid="sysTemManage_0_3" class="hide"><a href="/admin/manage/emailTempList"><i class="fa fa-envelope"></i> 邮件模板</a></li>
|
||||
<li cid="sysTemManage_0_4"><a href="/admin/manage/adsList"><i class="fa fa-camera-retro"></i> 广告管理</a></li>
|
||||
<li cid="sysTemManage_0_5"><a href="/admin/manage/filesList"><i class="fa fa-file-text"></i> 文件管理器</a></li>
|
||||
<li cid="sysTemManage_0_6">
|
||||
|
44
views/web/public/confirmEmail.ejs
Normal file
44
views/web/public/confirmEmail.ejs
Normal file
@ -0,0 +1,44 @@
|
||||
<!--用户登录模块-->
|
||||
<div class="conformBoard" ng-controller="confirmEmail">
|
||||
<form name="confirmEmailForm" ng-submit="processConfirmEmailForm(confirmEmailForm.$valid)" novalidate>
|
||||
<div class="alert alert-info">请输入您的用户名或电子邮箱地址。您会收到一封包含创建新密码链接的电子邮件。</div>
|
||||
<h3>找回密码 <small class="text-danger hide" id="errorInfo">邮箱和密码不匹配</small></h3>
|
||||
<div class="form-group">
|
||||
<input type="email" class="form-control" name="email" ng-model="confirmEmailData.email" placeholder="请填写电子邮件地址" required>
|
||||
<label for="inputError" class="control-label text-danger" ng-show="confirmEmailForm.email.$invalid && !loginForm.email.$pristine"><i class="fa fa-times-circle-o"></i>请填写正确的邮箱地址</label>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="ul-s5">
|
||||
<button type="submit" class="btn btn-default" ng-disabled="confirmEmailForm.$invalid">发送邮件</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
doraApp.controller("confirmEmail",function($scope,$http) {
|
||||
$scope.processConfirmEmailForm = function(isValid){
|
||||
|
||||
if(isValid){
|
||||
$http({
|
||||
method : 'POST',
|
||||
url : "/users/sentConfirmEmail",
|
||||
data : $.param($scope.confirmEmailData), // pass in data as strings
|
||||
headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload)
|
||||
})
|
||||
.success(function(data) {
|
||||
if(data === "success"){
|
||||
alert('邮件发送成功,请查看确认邮件!');
|
||||
window.location = '/';
|
||||
}else{
|
||||
|
||||
$('#errorInfo').removeClass('hide').html(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
alert("error");
|
||||
}
|
||||
};
|
||||
})
|
||||
</script>
|
@ -13,7 +13,8 @@
|
||||
|
||||
</div>
|
||||
<div id="ul-s5">
|
||||
<button type="submit" class="btn btn-default" ng-disabled="loginForm.$invalid">登录</button>
|
||||
<button type="submit" class="btn btn-default" ng-disabled="loginForm.$invalid">登录</button>
|
||||
<small><a href="/users/lostPassword">忘记密码?</a></small>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
20
views/web/public/notice.ejs
Normal file
20
views/web/public/notice.ejs
Normal file
@ -0,0 +1,20 @@
|
||||
<!--用户登录模块-->
|
||||
<div class="noticeBoard" >
|
||||
<form name="loginForm" ng-submit="processLogForm(loginForm.$valid)" novalidate>
|
||||
<h3>操作提示</h3>
|
||||
<%if(infoType == 'info'){%>
|
||||
<div class="alert alert-info"><%=infoContent%></div>
|
||||
<%}else if(infoType == 'success'){%>
|
||||
<div class="alert alert-success"><%=infoContent%></div>
|
||||
<%}else if(infoType == 'danger'){%>
|
||||
<div class="alert alert-danger"><%=infoContent%></div>
|
||||
<%}else if(infoType == 'warning'){%>
|
||||
<div class="alert alert-warning"><%=infoContent%></div>
|
||||
<%}%>
|
||||
<a href="/" class="btn btn-default" role="button">返回</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
65
views/web/public/reSetPsd.ejs
Normal file
65
views/web/public/reSetPsd.ejs
Normal file
@ -0,0 +1,65 @@
|
||||
<!--密码重置模块-->
|
||||
<div class="reSetPsdBoard" ng-controller="reSetPsd">
|
||||
<form name="reSetPsdForm" ng-submit="processReSetPsdForm(reSetPsdForm.$valid)" novalidate>
|
||||
<input type="hidden" value="<%=tokenId%>" id="tokenId"/>
|
||||
<h3>重设密码 <small class="text-danger hide" id="errorInfo">邮箱和密码不匹配</small></h3>
|
||||
<div class="form-group">
|
||||
|
||||
<input type="password" class="form-control" id="userPassword" name="password" ng-minlength="6" placeholder="请输入密码" ng-maxlength="12" ng-pattern="/^[a-zA-Z]\w{6,12}$/" ng-model="reSetPsdFormData.password" required/>
|
||||
<label for="inputError" class="control-label text-danger" ng-show="reSetPsdForm.password.$invalid && !regForm.password.$pristine"><i class="fa fa-times-circle-o"></i>6-12位,只能包含字母、数字和下划线</label>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<input type="password" class="form-control" pw-check="userPassword" name="confirmPassword" placeholder="请再次输入密码" ng-model="reSetPsdFormData.confirmPassword" ng-minlength="6" ng-maxlength="12" ng-pattern="/^[a-zA-Z0-9]{6,11}$/" required/>
|
||||
<label for="inputError" class="control-label text-danger" ng-show="reSetPsdForm.confirmPassword.$invalid && !regForm.confirmPassword.$pristine"><i class="fa fa-times-circle-o"></i>两次输入的密码不匹配</label>
|
||||
|
||||
</div>
|
||||
<div id="ul-s5">
|
||||
<button type="submit" class="btn btn-default" ng-disabled="reSetPsdForm.$invalid">提交</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
doraApp.controller("reSetPsd",function($scope,$http) {
|
||||
$scope.processReSetPsdForm = function(isValid){
|
||||
|
||||
if(isValid){
|
||||
|
||||
$scope.reSetPsdFormData.tokenId = $('#tokenId').val();
|
||||
$http({
|
||||
method : 'POST',
|
||||
url : "/users/updateNewPsd",
|
||||
data : $.param($scope.reSetPsdFormData), // pass in data as strings
|
||||
headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload)
|
||||
})
|
||||
.success(function(data) {
|
||||
if(data === "success"){
|
||||
alert('密码重置成功!');
|
||||
window.location = '/users/login';
|
||||
}else{
|
||||
$('#errorInfo').removeClass('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
alert("error");
|
||||
}
|
||||
};
|
||||
})
|
||||
.directive('pwCheck', [function () {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function (scope, elem, attrs, ctrl) {
|
||||
var firstPassword = '#' + attrs.pwCheck;
|
||||
elem.add(firstPassword).on('keyup', function () {
|
||||
scope.$apply(function () {
|
||||
var v = elem.val()===$(firstPassword).val();
|
||||
ctrl.$setValidity('pwmatch', v);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
</script>
|
7
views/web/users/userConfirmEmail.ejs
Normal file
7
views/web/users/userConfirmEmail.ejs
Normal file
@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-4 col-md-offset-4 min-hight" style="margin-top: 50px;">
|
||||
<% include ../public/confirmEmail %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
8
views/web/users/userNotice.ejs
Normal file
8
views/web/users/userNotice.ejs
Normal file
@ -0,0 +1,8 @@
|
||||
<div class="container">
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-8 col-md-offset-2 min-hight" style="margin-top: 50px;">
|
||||
<% include ../public/notice %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
8
views/web/users/userResetPsd.ejs
Normal file
8
views/web/users/userResetPsd.ejs
Normal file
@ -0,0 +1,8 @@
|
||||
<!--密码重置-->
|
||||
<div class="container">
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-4 col-md-offset-4 min-hight" style="margin-top: 50px;">
|
||||
<% include ../public/reSetPsd %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user