Skip to content

Commit

Permalink
remove user global
Browse files Browse the repository at this point in the history
  • Loading branch information
paul90 committed Nov 23, 2023
1 parent a38a1be commit d4014ac
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions server/social.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = exports = (log, loga, argv) ->

owner = ''
ownerName = ''
user = {}
wikiName = argv.url
wikiHost = argv.wiki_domain

Expand Down Expand Up @@ -215,10 +214,12 @@ module.exports = exports = (log, loga, argv) ->
username_query = 'params.user_id'

try
user.oauth2 = {
id: extractUserInfo(argv.oauth2_IdField, 'params.user_id')
username: extractUserInfo(argv.oauth2_UsernameField, 'params.user_id')
displayName: extractUserInfo(argv.oauth2_DisplayNameField, 'params.user_id')
user = {
oauth2: {
id: extractUserInfo(argv.oauth2_IdField, 'params.user_id')
username: extractUserInfo(argv.oauth2_UsernameField, 'params.user_id')
displayName: extractUserInfo(argv.oauth2_DisplayNameField, 'params.user_id')
}
}
catch e
console.error('*** Error extracting user info:', e)
Expand All @@ -239,11 +240,13 @@ module.exports = exports = (log, loga, argv) ->
# callbackURL is optional, and if it exists must match that given in
# the OAuth application settings - so we don't specify it.
}, (accessToken, refreshToken, profile, cb) ->
user.github = {
id: profile.id
username: profile.username
displayName: profile.displayName
emails: profile.emails
user = {
github: {
id: profile.id
username: profile.username
displayName: profile.displayName
emails: profile.emails
}
}
cb(null, user)))

Expand All @@ -259,10 +262,12 @@ module.exports = exports = (log, loga, argv) ->
consumerSecret: argv.twitter_consumerSecret
callbackURL: callbackProtocol + '//' + callbackHost + '/auth/twitter/callback'
}, (accessToken, refreshToken, profile, cb) ->
user.twitter = {
id: profile.id
username: profile.username
displayName: profile.displayName
user = {
twitter: {
id: profile.id
username: profile.username
displayName: profile.displayName
}
}
cb(null, user)))

Expand All @@ -278,11 +283,12 @@ module.exports = exports = (log, loga, argv) ->
clientSecret: argv.google_clientSecret
callbackURL: callbackProtocol + '//' + callbackHost + '/auth/google/callback'
}, (accessToken, refreshToken, profile, cb) ->
user.google = {
user = { google: {
id: profile.id
displayName: profile.displayName
emails: profile.emails
}
}
}
cb(null, user)))

app.use(passport.initialize())
Expand Down Expand Up @@ -535,7 +541,7 @@ module.exports = exports = (log, loga, argv) ->

app.get '/logout', (req, res) ->
console.log 'Logout...'
req.logout()
req.session.reset()
res.send("OK")

security

0 comments on commit d4014ac

Please sign in to comment.