mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-28 05:54:43 -04:00
Linter: Fix all lint errors
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
b0a45bdf9c
commit
136d895d15
51 changed files with 2245 additions and 1539 deletions
|
@ -6,7 +6,7 @@ const DropboxStrategy = require('passport-dropbox-oauth2').Strategy
|
|||
const config = require('../../../config')
|
||||
const { passportGeneralCallback } = require('../utils')
|
||||
|
||||
let dropboxAuth = module.exports = Router()
|
||||
const dropboxAuth = module.exports = Router()
|
||||
|
||||
passport.use(new DropboxStrategy({
|
||||
apiVersion: '2',
|
||||
|
|
|
@ -10,7 +10,7 @@ const logger = require('../../../logger')
|
|||
const { urlencodedParser } = require('../../utils')
|
||||
const errors = require('../../../errors')
|
||||
|
||||
let emailAuth = module.exports = Router()
|
||||
const emailAuth = module.exports = Router()
|
||||
|
||||
passport.use(new LocalStrategy({
|
||||
usernameField: 'email'
|
||||
|
|
|
@ -7,7 +7,7 @@ const FacebookStrategy = require('passport-facebook').Strategy
|
|||
const config = require('../../../config')
|
||||
const { passportGeneralCallback } = require('../utils')
|
||||
|
||||
let facebookAuth = module.exports = Router()
|
||||
const facebookAuth = module.exports = Router()
|
||||
|
||||
passport.use(new FacebookStrategy({
|
||||
clientID: config.facebook.clientID,
|
||||
|
|
|
@ -7,7 +7,7 @@ const config = require('../../../config')
|
|||
const response = require('../../../response')
|
||||
const { passportGeneralCallback } = require('../utils')
|
||||
|
||||
let githubAuth = module.exports = Router()
|
||||
const githubAuth = module.exports = Router()
|
||||
|
||||
passport.use(new GithubStrategy({
|
||||
clientID: config.github.clientID,
|
||||
|
|
|
@ -7,7 +7,7 @@ const config = require('../../../config')
|
|||
const response = require('../../../response')
|
||||
const { passportGeneralCallback } = require('../utils')
|
||||
|
||||
let gitlabAuth = module.exports = Router()
|
||||
const gitlabAuth = module.exports = Router()
|
||||
|
||||
passport.use(new GitlabStrategy({
|
||||
baseURL: config.gitlab.baseURL,
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
var GoogleStrategy = require('passport-google-oauth20').Strategy
|
||||
const GoogleStrategy = require('passport-google-oauth20').Strategy
|
||||
const config = require('../../../config')
|
||||
const { passportGeneralCallback } = require('../utils')
|
||||
|
||||
let googleAuth = module.exports = Router()
|
||||
const googleAuth = module.exports = Router()
|
||||
|
||||
passport.use(new GoogleStrategy({
|
||||
clientID: config.google.clientID,
|
||||
|
|
|
@ -9,7 +9,7 @@ const logger = require('../../../logger')
|
|||
const { urlencodedParser } = require('../../utils')
|
||||
const errors = require('../../../errors')
|
||||
|
||||
let ldapAuth = module.exports = Router()
|
||||
const ldapAuth = module.exports = Router()
|
||||
|
||||
passport.use(new LDAPStrategy({
|
||||
server: {
|
||||
|
@ -22,7 +22,7 @@ passport.use(new LDAPStrategy({
|
|||
tlsOptions: config.ldap.tlsOptions || null
|
||||
}
|
||||
}, function (user, done) {
|
||||
var uuid = user.uidNumber || user.uid || user.sAMAccountName || undefined
|
||||
let uuid = user.uidNumber || user.uid || user.sAMAccountName || undefined
|
||||
if (config.ldap.useridField && user[config.ldap.useridField]) {
|
||||
uuid = user[config.ldap.useridField]
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ passport.use(new LDAPStrategy({
|
|||
'"useridField" option in ldap settings.')
|
||||
}
|
||||
|
||||
var username = uuid
|
||||
let username = uuid
|
||||
if (config.ldap.usernameField && user[config.ldap.usernameField]) {
|
||||
username = user[config.ldap.usernameField]
|
||||
}
|
||||
|
||||
var profile = {
|
||||
const profile = {
|
||||
id: 'LDAP-' + uuid,
|
||||
username: username,
|
||||
displayName: user.displayName,
|
||||
|
@ -48,7 +48,7 @@ passport.use(new LDAPStrategy({
|
|||
profileUrl: null,
|
||||
provider: 'ldap'
|
||||
}
|
||||
var stringifiedProfile = JSON.stringify(profile)
|
||||
const stringifiedProfile = JSON.stringify(profile)
|
||||
models.User.findOrCreate({
|
||||
where: {
|
||||
profileid: profile.id.toString()
|
||||
|
@ -58,7 +58,7 @@ passport.use(new LDAPStrategy({
|
|||
}
|
||||
}).spread(function (user, created) {
|
||||
if (user) {
|
||||
var needSave = false
|
||||
let needSave = false
|
||||
if (user.profile !== stringifiedProfile) {
|
||||
user.profile = stringifiedProfile
|
||||
needSave = true
|
||||
|
|
|
@ -9,9 +9,9 @@ const { passportGeneralCallback } = require('../utils')
|
|||
|
||||
const mattermost = new Mattermost.Client()
|
||||
|
||||
let mattermostAuth = module.exports = Router()
|
||||
const mattermostAuth = module.exports = Router()
|
||||
|
||||
let mattermostStrategy = new OAuthStrategy({
|
||||
const mattermostStrategy = new OAuthStrategy({
|
||||
authorizationURL: config.mattermost.baseURL + '/oauth/authorize',
|
||||
tokenURL: config.mattermost.baseURL + '/oauth/access_token',
|
||||
clientID: config.mattermost.clientID,
|
||||
|
|
|
@ -7,7 +7,7 @@ const config = require('../../../config')
|
|||
const logger = require('../../../logger')
|
||||
const { passportGeneralCallback } = require('../utils')
|
||||
|
||||
let oauth2Auth = module.exports = Router()
|
||||
const oauth2Auth = module.exports = Router()
|
||||
|
||||
class OAuth2CustomStrategy extends Strategy {
|
||||
constructor (options, verify) {
|
||||
|
@ -20,7 +20,7 @@ class OAuth2CustomStrategy extends Strategy {
|
|||
|
||||
userProfile (accessToken, done) {
|
||||
this._oauth2.get(this._userProfileURL, accessToken, function (err, body, res) {
|
||||
var json
|
||||
let json
|
||||
|
||||
if (err) {
|
||||
return done(new InternalOAuthError('Failed to fetch user profile', err))
|
||||
|
@ -33,7 +33,7 @@ class OAuth2CustomStrategy extends Strategy {
|
|||
}
|
||||
|
||||
checkAuthorization(json, done)
|
||||
let profile = parseProfile(json)
|
||||
const profile = parseProfile(json)
|
||||
profile.provider = 'oauth2'
|
||||
|
||||
done(null, profile)
|
||||
|
@ -91,7 +91,7 @@ function checkAuthorization (data, done) {
|
|||
|
||||
OAuth2CustomStrategy.prototype.userProfile = function (accessToken, done) {
|
||||
this._oauth2.get(this._userProfileURL, accessToken, function (err, body, res) {
|
||||
var json
|
||||
let json
|
||||
|
||||
if (err) {
|
||||
return done(new InternalOAuthError('Failed to fetch user profile', err))
|
||||
|
@ -104,7 +104,7 @@ OAuth2CustomStrategy.prototype.userProfile = function (accessToken, done) {
|
|||
}
|
||||
|
||||
checkAuthorization(json, done)
|
||||
let profile = parseProfile(json)
|
||||
const profile = parseProfile(json)
|
||||
profile.provider = 'oauth2'
|
||||
|
||||
done(null, profile)
|
||||
|
|
|
@ -8,14 +8,14 @@ const models = require('../../../models')
|
|||
const logger = require('../../../logger')
|
||||
const { urlencodedParser } = require('../../utils')
|
||||
|
||||
let openIDAuth = module.exports = Router()
|
||||
const openIDAuth = module.exports = Router()
|
||||
|
||||
passport.use(new OpenIDStrategy({
|
||||
returnURL: config.serverURL + '/auth/openid/callback',
|
||||
realm: config.serverURL,
|
||||
profile: true
|
||||
}, function (openid, profile, done) {
|
||||
var stringifiedProfile = JSON.stringify(profile)
|
||||
const stringifiedProfile = JSON.stringify(profile)
|
||||
models.User.findOrCreate({
|
||||
where: {
|
||||
profileid: openid
|
||||
|
@ -25,7 +25,7 @@ passport.use(new OpenIDStrategy({
|
|||
}
|
||||
}).spread(function (user, created) {
|
||||
if (user) {
|
||||
var needSave = false
|
||||
let needSave = false
|
||||
if (user.profile !== stringifiedProfile) {
|
||||
user.profile = stringifiedProfile
|
||||
needSave = true
|
||||
|
|
|
@ -10,19 +10,21 @@ const { urlencodedParser } = require('../../utils')
|
|||
const fs = require('fs')
|
||||
const intersection = function (array1, array2) { return array1.filter((n) => array2.includes(n)) }
|
||||
|
||||
let samlAuth = module.exports = Router()
|
||||
const samlAuth = module.exports = Router()
|
||||
|
||||
passport.use(new SamlStrategy({
|
||||
callbackUrl: config.serverURL + '/auth/saml/callback',
|
||||
entryPoint: config.saml.idpSsoUrl,
|
||||
issuer: config.saml.issuer || config.serverURL,
|
||||
privateCert: config.saml.clientCert === undefined ? undefined : (function () {
|
||||
try {
|
||||
return fs.readFileSync(config.saml.clientCert, 'utf-8')
|
||||
} catch (e) {
|
||||
logger.error(`SAML client certificate: ${e.message}`)
|
||||
}
|
||||
}()),
|
||||
privateCert: config.saml.clientCert === undefined
|
||||
? undefined
|
||||
: (function () {
|
||||
try {
|
||||
return fs.readFileSync(config.saml.clientCert, 'utf-8')
|
||||
} catch (e) {
|
||||
logger.error(`SAML client certificate: ${e.message}`)
|
||||
}
|
||||
}()),
|
||||
cert: (function () {
|
||||
try {
|
||||
return fs.readFileSync(config.saml.idpCert, 'utf-8')
|
||||
|
@ -36,7 +38,7 @@ passport.use(new SamlStrategy({
|
|||
}, function (user, done) {
|
||||
// check authorization if needed
|
||||
if (config.saml.externalGroups && config.saml.groupAttribute) {
|
||||
var externalGroups = intersection(config.saml.externalGroups, user[config.saml.groupAttribute])
|
||||
const externalGroups = intersection(config.saml.externalGroups, user[config.saml.groupAttribute])
|
||||
if (externalGroups.length > 0) {
|
||||
logger.error('saml permission denied: ' + externalGroups.join(', '))
|
||||
return done('Permission denied', null)
|
||||
|
@ -49,8 +51,8 @@ passport.use(new SamlStrategy({
|
|||
}
|
||||
}
|
||||
// user creation
|
||||
var uuid = user[config.saml.attribute.id] || user.nameID
|
||||
var profile = {
|
||||
const uuid = user[config.saml.attribute.id] || user.nameID
|
||||
const profile = {
|
||||
provider: 'saml',
|
||||
id: 'SAML-' + uuid,
|
||||
username: user[config.saml.attribute.username] || user.nameID,
|
||||
|
@ -59,7 +61,7 @@ passport.use(new SamlStrategy({
|
|||
if (profile.emails.length === 0 && config.saml.identifierFormat === 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress') {
|
||||
profile.emails.push(user.nameID)
|
||||
}
|
||||
var stringifiedProfile = JSON.stringify(profile)
|
||||
const stringifiedProfile = JSON.stringify(profile)
|
||||
models.User.findOrCreate({
|
||||
where: {
|
||||
profileid: profile.id.toString()
|
||||
|
@ -69,7 +71,7 @@ passport.use(new SamlStrategy({
|
|||
}
|
||||
}).spread(function (user, created) {
|
||||
if (user) {
|
||||
var needSave = false
|
||||
let needSave = false
|
||||
if (user.profile !== stringifiedProfile) {
|
||||
user.profile = stringifiedProfile
|
||||
needSave = true
|
||||
|
|
|
@ -7,7 +7,7 @@ const TwitterStrategy = require('passport-twitter').Strategy
|
|||
const config = require('../../../config')
|
||||
const { passportGeneralCallback } = require('../utils')
|
||||
|
||||
let twitterAuth = module.exports = Router()
|
||||
const twitterAuth = module.exports = Router()
|
||||
|
||||
passport.use(new TwitterStrategy({
|
||||
consumerKey: config.twitter.consumerKey,
|
||||
|
|
|
@ -4,7 +4,7 @@ const models = require('../../models')
|
|||
const logger = require('../../logger')
|
||||
|
||||
exports.passportGeneralCallback = function callback (accessToken, refreshToken, profile, done) {
|
||||
var stringifiedProfile = JSON.stringify(profile)
|
||||
const stringifiedProfile = JSON.stringify(profile)
|
||||
models.User.findOrCreate({
|
||||
where: {
|
||||
profileid: profile.id.toString()
|
||||
|
@ -16,7 +16,7 @@ exports.passportGeneralCallback = function callback (accessToken, refreshToken,
|
|||
}
|
||||
}).spread(function (user, created) {
|
||||
if (user) {
|
||||
var needSave = false
|
||||
let needSave = false
|
||||
if (user.profile !== stringifiedProfile) {
|
||||
user.profile = stringifiedProfile
|
||||
needSave = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue