Revert "add new logic for restricted wikis"

This reverts commit 5d7c53d1a2.
This commit is contained in:
3wc
2024-10-30 22:21:19 -04:00
parent 5d7c53d1a2
commit cb9e0ceed3

View File

@ -385,31 +385,24 @@ module.exports = exports = (log, loga, argv) ->
# see http://ward.asia.wiki.org/login-to-view.html # see http://ward.asia.wiki.org/login-to-view.html
if argv.restricted? if argv.restricted?
allowedToView = (req) -> allowedToView = (req) ->
allowed = []
if argv.allowed_domains? if argv.allowed_domains?
try if Array.isArray(argv.allowed_domains)
allowed_domains = argv.allowed_domains allowed = argv.allowed_domains
emails = req.session.passport.user.google.emails else
for entry in emails # accommodate copy bug to be fixed soon
have = entry.value.split('@')[1] # https://github.com/fedwiki/wiki/blob/4c6eee69e78c1ba3f3fc8d61f4450f70afb78f10/farm.coffee#L98-L103
for want in allowed_domains for k, v of argv.allowed_domains
return true if want == have allowed.push v
catch error # emails = [ { value: 'ward.cunningham@gmail.com', type: 'account' } ]
if emails? emails = req.session?.passport?.user?.google?.emails
console.log "argv.allowed_domains exists, but there was an error. Make sure it's value is an array in your config." return false unless emails
if argv.allowed_ids? for entry in emails
try have = entry.value.split('@')[1]
allowed_ids = argv.allowed_ids for want in allowed
idProvider = _.head(_.keys(req.session.passport.user)) return true if want == have
switch idProvider
when 'github', 'twitter', 'oauth2'
id = req.session.passport.user[idProvider].id
return true if (allowed_ids.length == 1 and allowed_ids[0] == "*")
for want in allowed_ids
return true if want == id
catch error
if idProvider?
console.log "argv.allowed_ids exists, but there was an error. Make sure it's value is an array in your config."
false false
app.all '*', (req, res, next) -> app.all '*', (req, res, next) ->