mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
Change config to camel case with backwards compatibility
This refactors the configs a bit to now use camel case everywhere. This change should help to clean up the config interface and make it better understandable. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
This commit is contained in:
parent
fa4a8418af
commit
2411dffa2c
29 changed files with 290 additions and 237 deletions
|
@ -12,7 +12,7 @@ passport.use(new DropboxStrategy({
|
|||
apiVersion: '2',
|
||||
clientID: config.dropbox.clientID,
|
||||
clientSecret: config.dropbox.clientSecret,
|
||||
callbackURL: config.serverurl + '/auth/dropbox/callback'
|
||||
callbackURL: config.serverURL + '/auth/dropbox/callback'
|
||||
}, passportGeneralCallback))
|
||||
|
||||
dropboxAuth.get('/auth/dropbox', function (req, res, next) {
|
||||
|
@ -23,7 +23,7 @@ dropboxAuth.get('/auth/dropbox', function (req, res, next) {
|
|||
// dropbox auth callback
|
||||
dropboxAuth.get('/auth/dropbox/callback',
|
||||
passport.authenticate('dropbox-oauth2', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
|
|
@ -31,7 +31,7 @@ passport.use(new LocalStrategy({
|
|||
})
|
||||
}))
|
||||
|
||||
if (config.allowemailregister) {
|
||||
if (config.allowEmailRegister) {
|
||||
emailAuth.post('/register', urlencodedParser, function (req, res, next) {
|
||||
if (!req.body.email || !req.body.password) return response.errorBadRequest(res)
|
||||
if (!validator.isEmail(req.body.email)) return response.errorBadRequest(res)
|
||||
|
@ -51,10 +51,10 @@ if (config.allowemailregister) {
|
|||
logger.debug('user found: ' + user.id)
|
||||
req.flash('error', 'This email has been used, please try another one.')
|
||||
}
|
||||
return res.redirect(config.serverurl + '/')
|
||||
return res.redirect(config.serverURL + '/')
|
||||
}
|
||||
req.flash('error', 'Failed to register your account, please try again.')
|
||||
return res.redirect(config.serverurl + '/')
|
||||
return res.redirect(config.serverURL + '/')
|
||||
}).catch(function (err) {
|
||||
logger.error('auth callback failed: ' + err)
|
||||
return response.errorInternalError(res)
|
||||
|
@ -67,8 +67,8 @@ emailAuth.post('/login', urlencodedParser, function (req, res, next) {
|
|||
if (!validator.isEmail(req.body.email)) return response.errorBadRequest(res)
|
||||
setReturnToFromReferer(req)
|
||||
passport.authenticate('local', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/',
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/',
|
||||
failureFlash: 'Invalid email or password.'
|
||||
})(req, res, next)
|
||||
})
|
||||
|
|
|
@ -12,7 +12,7 @@ let facebookAuth = module.exports = Router()
|
|||
passport.use(new FacebookStrategy({
|
||||
clientID: config.facebook.clientID,
|
||||
clientSecret: config.facebook.clientSecret,
|
||||
callbackURL: config.serverurl + '/auth/facebook/callback'
|
||||
callbackURL: config.serverURL + '/auth/facebook/callback'
|
||||
}, passportGeneralCallback))
|
||||
|
||||
facebookAuth.get('/auth/facebook', function (req, res, next) {
|
||||
|
@ -23,7 +23,7 @@ facebookAuth.get('/auth/facebook', function (req, res, next) {
|
|||
// facebook auth callback
|
||||
facebookAuth.get('/auth/facebook/callback',
|
||||
passport.authenticate('facebook', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
|
|
@ -12,7 +12,7 @@ let githubAuth = module.exports = Router()
|
|||
passport.use(new GithubStrategy({
|
||||
clientID: config.github.clientID,
|
||||
clientSecret: config.github.clientSecret,
|
||||
callbackURL: config.serverurl + '/auth/github/callback'
|
||||
callbackURL: config.serverURL + '/auth/github/callback'
|
||||
}, passportGeneralCallback))
|
||||
|
||||
githubAuth.get('/auth/github', function (req, res, next) {
|
||||
|
@ -23,8 +23,8 @@ githubAuth.get('/auth/github', function (req, res, next) {
|
|||
// github auth callback
|
||||
githubAuth.get('/auth/github/callback',
|
||||
passport.authenticate('github', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ passport.use(new GitlabStrategy({
|
|||
clientID: config.gitlab.clientID,
|
||||
clientSecret: config.gitlab.clientSecret,
|
||||
scope: config.gitlab.scope,
|
||||
callbackURL: config.serverurl + '/auth/gitlab/callback'
|
||||
callbackURL: config.serverURL + '/auth/gitlab/callback'
|
||||
}, passportGeneralCallback))
|
||||
|
||||
gitlabAuth.get('/auth/gitlab', function (req, res, next) {
|
||||
|
@ -25,8 +25,8 @@ gitlabAuth.get('/auth/gitlab', function (req, res, next) {
|
|||
// gitlab auth callback
|
||||
gitlabAuth.get('/auth/gitlab/callback',
|
||||
passport.authenticate('gitlab', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ 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'
|
||||
}, passportGeneralCallback))
|
||||
|
||||
googleAuth.get('/auth/google', function (req, res, next) {
|
||||
|
@ -21,7 +21,7 @@ googleAuth.get('/auth/google', function (req, res, next) {
|
|||
// google auth callback
|
||||
googleAuth.get('/auth/google/callback',
|
||||
passport.authenticate('google', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
|
|
@ -51,5 +51,5 @@ authRouter.get('/logout', function (req, res) {
|
|||
logger.debug('user logout: ' + req.user.id)
|
||||
}
|
||||
req.logout()
|
||||
res.redirect(config.serverurl + '/')
|
||||
res.redirect(config.serverURL + '/')
|
||||
})
|
||||
|
|
|
@ -84,8 +84,8 @@ ldapAuth.post('/auth/ldap', urlencodedParser, function (req, res, next) {
|
|||
if (!req.body.username || !req.body.password) return response.errorBadRequest(res)
|
||||
setReturnToFromReferer(req)
|
||||
passport.authenticate('ldapauth', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/',
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/',
|
||||
failureFlash: true
|
||||
})(req, res, next)
|
||||
})
|
||||
|
|
|
@ -16,7 +16,7 @@ let mattermostStrategy = new OAuthStrategy({
|
|||
tokenURL: config.mattermost.baseURL + '/oauth/access_token',
|
||||
clientID: config.mattermost.clientID,
|
||||
clientSecret: config.mattermost.clientSecret,
|
||||
callbackURL: config.serverurl + '/auth/mattermost/callback'
|
||||
callbackURL: config.serverURL + '/auth/mattermost/callback'
|
||||
}, passportGeneralCallback)
|
||||
|
||||
mattermostStrategy.userProfile = (accessToken, done) => {
|
||||
|
@ -43,7 +43,7 @@ mattermostAuth.get('/auth/mattermost', function (req, res, next) {
|
|||
// mattermost auth callback
|
||||
mattermostAuth.get('/auth/mattermost/callback',
|
||||
passport.authenticate('oauth2', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
|
|
@ -13,9 +13,9 @@ const intersection = function (array1, array2) { return array1.filter((n) => arr
|
|||
let samlAuth = module.exports = Router()
|
||||
|
||||
passport.use(new SamlStrategy({
|
||||
callbackUrl: config.serverurl + '/auth/saml/callback',
|
||||
callbackUrl: config.serverURL + '/auth/saml/callback',
|
||||
entryPoint: config.saml.idpSsoUrl,
|
||||
issuer: config.saml.issuer || config.serverurl,
|
||||
issuer: config.saml.issuer || config.serverURL,
|
||||
cert: fs.readFileSync(config.saml.idpCert, 'utf-8'),
|
||||
identifierFormat: config.saml.identifierFormat
|
||||
}, function (user, done) {
|
||||
|
@ -77,15 +77,15 @@ passport.use(new SamlStrategy({
|
|||
|
||||
samlAuth.get('/auth/saml',
|
||||
passport.authenticate('saml', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
||||
samlAuth.post('/auth/saml/callback', urlencodedParser,
|
||||
passport.authenticate('saml', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ let twitterAuth = module.exports = Router()
|
|||
passport.use(new TwitterStrategy({
|
||||
consumerKey: config.twitter.consumerKey,
|
||||
consumerSecret: config.twitter.consumerSecret,
|
||||
callbackURL: config.serverurl + '/auth/twitter/callback'
|
||||
callbackURL: config.serverURL + '/auth/twitter/callback'
|
||||
}, passportGeneralCallback))
|
||||
|
||||
twitterAuth.get('/auth/twitter', function (req, res, next) {
|
||||
|
@ -23,7 +23,7 @@ twitterAuth.get('/auth/twitter', function (req, res, next) {
|
|||
// twitter auth callback
|
||||
twitterAuth.get('/auth/twitter/callback',
|
||||
passport.authenticate('twitter', {
|
||||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue