Added own profile save + dependencies update
This commit is contained in:
parent
2d354d61d6
commit
f2dd84a0e4
3
agent.js
3
agent.js
@ -42,6 +42,7 @@ var _ = require('lodash');
|
|||||||
var moment = require('moment');
|
var moment = require('moment');
|
||||||
var Promise = require('bluebird');
|
var Promise = require('bluebird');
|
||||||
var fs = Promise.promisifyAll(require("fs-extra"));
|
var fs = Promise.promisifyAll(require("fs-extra"));
|
||||||
|
var klaw = require('klaw');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var cron = require('cron').CronJob;
|
var cron = require('cron').CronJob;
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ var job = new cron({
|
|||||||
jobCbStreamDocs_resolve = resolve;
|
jobCbStreamDocs_resolve = resolve;
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.walk(repoPath).on('data', function (item) {
|
klaw(repoPath).on('data', function (item) {
|
||||||
if(path.extname(item.path) === '.md' && path.basename(item.path) !== 'README.md') {
|
if(path.extname(item.path) === '.md' && path.basename(item.path) !== 'README.md') {
|
||||||
|
|
||||||
let entryPath = entries.parsePath(entries.getEntryPathFromFullPath(item.path));
|
let entryPath = entries.parsePath(entries.getEntryPathFromFullPath(item.path));
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,5 +1,35 @@
|
|||||||
|
|
||||||
if($('#page-type-admin-users').length) {
|
if($('#page-type-admin-profile').length) {
|
||||||
|
|
||||||
|
let vueProfile = new Vue({
|
||||||
|
el: '#page-type-admin-profile',
|
||||||
|
data: {
|
||||||
|
password: '********',
|
||||||
|
passwordVerify: '********',
|
||||||
|
name: ''
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
saveUser: (ev) => {
|
||||||
|
if(vueProfile.password !== vueProfile.passwordVerify) {
|
||||||
|
alerts.pushError('Error', "Passwords don't match!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$.post(window.location.href, {
|
||||||
|
password: vueProfile.password,
|
||||||
|
name: vueProfile.name
|
||||||
|
}).done((resp) => {
|
||||||
|
alerts.pushSuccess('Saved successfully', 'Changes have been applied.');
|
||||||
|
}).fail((jqXHR, txtStatus, resp) => {
|
||||||
|
alerts.pushError('Error', resp);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created: function() {
|
||||||
|
this.name = usrDataName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else if($('#page-type-admin-users').length) {
|
||||||
|
|
||||||
//=include ../modals/admin-users-create.js
|
//=include ../modals/admin-users-create.js
|
||||||
|
|
||||||
|
@ -23,6 +23,35 @@ router.get('/profile', (req, res) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/profile', (req, res) => {
|
||||||
|
|
||||||
|
if(res.locals.isGuest) {
|
||||||
|
return res.render('error-forbidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
return db.User.findById(req.user.id).then((usr) => {
|
||||||
|
usr.name = _.trim(req.body.name);
|
||||||
|
if(usr.provider === 'local' && req.body.password !== '********') {
|
||||||
|
let nPwd = _.trim(req.body.password);
|
||||||
|
if(nPwd.length < 6) {
|
||||||
|
return Promise.reject(new Error('New Password too short!'))
|
||||||
|
} else {
|
||||||
|
return db.User.hashPassword(nPwd).then((pwd) => {
|
||||||
|
usr.password = pwd;
|
||||||
|
return usr.save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return usr.save();
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
return res.json({ msg: 'OK' });
|
||||||
|
}).catch((err) => {
|
||||||
|
res.status(400).json({ msg: err.message });
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/stats', (req, res) => {
|
router.get('/stats', (req, res) => {
|
||||||
|
|
||||||
if(res.locals.isGuest) {
|
if(res.locals.isGuest) {
|
||||||
|
19
package.json
19
package.json
@ -51,13 +51,14 @@
|
|||||||
"farmhash": "^1.2.1",
|
"farmhash": "^1.2.1",
|
||||||
"file-type": "^4.0.0",
|
"file-type": "^4.0.0",
|
||||||
"filesize.js": "^1.0.2",
|
"filesize.js": "^1.0.2",
|
||||||
"fs-extra": "^1.0.0",
|
"fs-extra": "^2.0.0",
|
||||||
"git-wrapper2-promise": "^0.2.9",
|
"git-wrapper2-promise": "^0.2.9",
|
||||||
"highlight.js": "^9.9.0",
|
"highlight.js": "^9.9.0",
|
||||||
"i18next": "^4.1.4",
|
"i18next": "^6.0.3",
|
||||||
"i18next-express-middleware": "^1.0.2",
|
"i18next-express-middleware": "^1.0.2",
|
||||||
"i18next-node-fs-backend": "^0.1.3",
|
"i18next-node-fs-backend": "^0.1.3",
|
||||||
"js-yaml": "^3.7.0",
|
"js-yaml": "^3.7.0",
|
||||||
|
"klaw": "^1.3.1",
|
||||||
"lodash": "^4.17.3",
|
"lodash": "^4.17.3",
|
||||||
"markdown-it": "^8.2.2",
|
"markdown-it": "^8.2.2",
|
||||||
"markdown-it-abbr": "^1.0.4",
|
"markdown-it-abbr": "^1.0.4",
|
||||||
@ -79,14 +80,14 @@
|
|||||||
"passport-local": "^1.0.0",
|
"passport-local": "^1.0.0",
|
||||||
"passport-windowslive": "^1.0.2",
|
"passport-windowslive": "^1.0.2",
|
||||||
"passport.socketio": "^3.7.0",
|
"passport.socketio": "^3.7.0",
|
||||||
"pug": "^2.0.0-beta6",
|
"pug": "^2.0.0-beta10",
|
||||||
"read-chunk": "^2.0.0",
|
"read-chunk": "^2.0.0",
|
||||||
"remove-markdown": "^0.1.0",
|
"remove-markdown": "^0.1.0",
|
||||||
"requarks-core": "github:requarks/core",
|
"requarks-core": "^0.2.0",
|
||||||
"request": "^2.79.0",
|
"request": "^2.79.0",
|
||||||
"search-index": "^0.9.9",
|
"search-index": "^0.9.9",
|
||||||
"serve-favicon": "^2.3.2",
|
"serve-favicon": "^2.3.2",
|
||||||
"sharp": "^0.17.0",
|
"sharp": "^0.17.1",
|
||||||
"simplemde": "^1.11.2",
|
"simplemde": "^1.11.2",
|
||||||
"socket.io": "^1.7.2",
|
"socket.io": "^1.7.2",
|
||||||
"sticky-js": "^1.0.7",
|
"sticky-js": "^1.0.7",
|
||||||
@ -112,7 +113,7 @@
|
|||||||
"gulp-tar": "^1.9.0",
|
"gulp-tar": "^1.9.0",
|
||||||
"gulp-uglify": "^2.0.0",
|
"gulp-uglify": "^2.0.0",
|
||||||
"gulp-watch": "^4.3.11",
|
"gulp-watch": "^4.3.11",
|
||||||
"gulp-zip": "^3.2.0",
|
"gulp-zip": "^4.0.0",
|
||||||
"istanbul": "^0.4.5",
|
"istanbul": "^0.4.5",
|
||||||
"jquery": "^3.1.1",
|
"jquery": "^3.1.1",
|
||||||
"jquery-contextmenu": "^2.4.1",
|
"jquery-contextmenu": "^2.4.1",
|
||||||
@ -123,10 +124,10 @@
|
|||||||
"mocha-lcov-reporter": "^1.2.0",
|
"mocha-lcov-reporter": "^1.2.0",
|
||||||
"nodemon": "^1.11.0",
|
"nodemon": "^1.11.0",
|
||||||
"run-sequence": "^1.2.2",
|
"run-sequence": "^1.2.2",
|
||||||
"snyk": "^1.22.1",
|
"snyk": "^1.24.6",
|
||||||
"sticky-js": "^1.1.6",
|
"sticky-js": "^1.1.8",
|
||||||
"twemoji-awesome": "^1.0.4",
|
"twemoji-awesome": "^1.0.4",
|
||||||
"vue": "^2.1.7"
|
"vue": "^2.1.10"
|
||||||
},
|
},
|
||||||
"snyk": true
|
"snyk": true
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,49 @@
|
|||||||
extends ./_layout.pug
|
extends ./_layout.pug
|
||||||
|
|
||||||
block adminContent
|
block adminContent
|
||||||
.hero
|
#page-type-admin-profile
|
||||||
h1.title#title My Profile
|
.hero
|
||||||
h2.subtitle Profile and authentication info
|
h1.title#title My Profile
|
||||||
.form-sections
|
h2.subtitle Profile and authentication info
|
||||||
.columns.is-gapless
|
.form-sections
|
||||||
.column.is-two-thirds
|
.columns.is-gapless
|
||||||
section
|
.column.is-two-thirds
|
||||||
label.label Email
|
|
||||||
p.control.is-fullwidth
|
|
||||||
input.input(type='text', placeholder='Email', value=user.email, disabled=(user.provider !== 'local'))
|
|
||||||
if user.provider == 'local'
|
|
||||||
section
|
section
|
||||||
label.label Password
|
label.label Email
|
||||||
p.control.is-fullwidth
|
p.control.is-fullwidth
|
||||||
input.input(type='password', placeholder='Password', value='********')
|
input.input(type='text', placeholder='Email', value=user.email, disabled)
|
||||||
|
if user.provider == 'local'
|
||||||
|
section
|
||||||
|
label.label Password
|
||||||
|
p.control.is-fullwidth
|
||||||
|
input.input(type='password', placeholder='Password', value='********', v-model='password')
|
||||||
|
section
|
||||||
|
label.label Verify Password
|
||||||
|
p.control.is-fullwidth
|
||||||
|
input.input(type='password', placeholder='Password', value='********', v-model='passwordVerify')
|
||||||
section
|
section
|
||||||
label.label Verify Password
|
label.label Display Name
|
||||||
p.control.is-fullwidth
|
p.control.is-fullwidth
|
||||||
input.input(type='password', placeholder='Password', value='********')
|
input.input(type='text', placeholder='John Smith', v-model='name')
|
||||||
section
|
section
|
||||||
label.label Display Name
|
button.button.is-green(v-on:click='saveUser')
|
||||||
p.control.is-fullwidth
|
i.icon-check
|
||||||
input.input(type='text', placeholder='John Smith', value=user.name)
|
span Save Changes
|
||||||
section
|
.column
|
||||||
button.button.is-green
|
.panel
|
||||||
i.icon-check
|
label.label Provider
|
||||||
span Save Changes
|
p.control.account-profile-provider
|
||||||
.column
|
case user.provider
|
||||||
.panel
|
when 'local': i.icon-server
|
||||||
label.label Provider
|
when 'windowslive': i.icon-windows2.is-blue
|
||||||
p.control.account-profile-provider
|
when 'google': i.icon-google.is-blue
|
||||||
case user.provider
|
when 'facebook': i.icon-facebook.is-purple
|
||||||
when 'local': i.icon-server
|
default: i.icon-warning
|
||||||
when 'windowslive': i.icon-windows2.is-blue
|
= t('auth:providers.' + user.provider)
|
||||||
when 'google': i.icon-google.is-blue
|
label.label Member since
|
||||||
when 'facebook': i.icon-facebook.is-purple
|
p.control= userMoment(user.createdAt).format('LL')
|
||||||
default: i.icon-warning
|
label.label Last Profile Update
|
||||||
= t('auth:providers.' + user.provider)
|
p.control= userMoment(user.updatedAt).format('LL')
|
||||||
label.label Member since
|
|
||||||
p.control= userMoment(user.createdAt).format('LL')
|
script(type='text/javascript').
|
||||||
label.label Last Profile Update
|
var usrDataName = "!{user.name}";
|
||||||
p.control= userMoment(user.updatedAt).format('LL')
|
|
Loading…
x
Reference in New Issue
Block a user