summaryrefslogtreecommitdiff
path: root/lib/web
diff options
context:
space:
mode:
Diffstat (limited to 'lib/web')
-rw-r--r--lib/web/auth/google/index.js3
-rw-r--r--lib/web/auth/oauth2/index.js4
-rw-r--r--lib/web/auth/openid/index.js4
-rw-r--r--lib/web/imageRouter/filesystem.js4
-rw-r--r--lib/web/userRouter.js20
5 files changed, 19 insertions, 16 deletions
diff --git a/lib/web/auth/google/index.js b/lib/web/auth/google/index.js
index 60282cf5..0a4fd55e 100644
--- a/lib/web/auth/google/index.js
+++ b/lib/web/auth/google/index.js
@@ -11,7 +11,8 @@ let googleAuth = module.exports = Router()
passport.use(new GoogleStrategy({
clientID: config.google.clientID,
clientSecret: config.google.clientSecret,
- callbackURL: config.serverURL + '/auth/google/callback'
+ callbackURL: config.serverURL + '/auth/google/callback',
+ userProfileURL: "https://www.googleapis.com/oauth2/v3/userinfo"
}, passportGeneralCallback))
googleAuth.get('/auth/google', function (req, res, next) {
diff --git a/lib/web/auth/oauth2/index.js b/lib/web/auth/oauth2/index.js
index b9160f6e..57ab9b9a 100644
--- a/lib/web/auth/oauth2/index.js
+++ b/lib/web/auth/oauth2/index.js
@@ -100,7 +100,7 @@ oauth2Auth.get('/auth/oauth2', function (req, res, next) {
// github auth callback
oauth2Auth.get('/auth/oauth2/callback',
passport.authenticate('oauth2', {
- successReturnToOrRedirect: config.serverurl + '/',
- failureRedirect: config.serverurl + '/'
+ successReturnToOrRedirect: config.serverURL + '/',
+ failureRedirect: config.serverURL + '/'
})
)
diff --git a/lib/web/auth/openid/index.js b/lib/web/auth/openid/index.js
index 96f61807..c45c6d71 100644
--- a/lib/web/auth/openid/index.js
+++ b/lib/web/auth/openid/index.js
@@ -55,7 +55,7 @@ openIDAuth.post('/auth/openid', urlencodedParser, function (req, res, next) {
// openID auth callback
openIDAuth.get('/auth/openid/callback',
passport.authenticate('openid', {
- successReturnToOrRedirect: config.serverurl + '/',
- failureRedirect: config.serverurl + '/'
+ successReturnToOrRedirect: config.serverURL + '/',
+ failureRedirect: config.serverURL + '/'
})
)
diff --git a/lib/web/imageRouter/filesystem.js b/lib/web/imageRouter/filesystem.js
index a2f8700d..7c876d66 100644
--- a/lib/web/imageRouter/filesystem.js
+++ b/lib/web/imageRouter/filesystem.js
@@ -1,5 +1,5 @@
'use strict'
-const url = require('url')
+const URL = require('url').URL
const path = require('path')
const config = require('../../config')
@@ -16,5 +16,5 @@ exports.uploadImage = function (imagePath, callback) {
return
}
- callback(null, url.URL.resolve(config.serverURL + '/uploads/', path.basename(imagePath)))
+ callback(null, (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href)
}
diff --git a/lib/web/userRouter.js b/lib/web/userRouter.js
index db786d53..ca364422 100644
--- a/lib/web/userRouter.js
+++ b/lib/web/userRouter.js
@@ -90,18 +90,20 @@ UserRouter.get('/me/export', function (req, res) {
ownerId: user.id
}
}).then(function (notes) {
- let list = []
+ let filenames = {}
async.each(notes, function (note, callback) {
- let title
- let extension = ''
+ let basename = note.title.replace(/\//g, '-') // Prevent subdirectories
+ let filename
+ let suffix = ''
do {
- title = note.title + extension
- extension++
- } while (list.indexOf(title) !== -1)
+ let seperator = typeof suffix === 'number' ? '-' : ''
+ filename = basename + seperator + suffix + '.md'
+ suffix++
+ } while (filenames[filename])
+ filenames[filename] = true
- list.push(title)
- logger.debug('Write: ' + title + '.md')
- archive.append(Buffer.from(note.content), { name: title + '.md', date: note.lastchangeAt })
+ logger.debug('Write: ' + filename)
+ archive.append(Buffer.from(note.content), { name: filename, date: note.lastchangeAt })
callback(null, null)
}, function (err) {
if (err) {