mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
block sso registration for institutional sso domains
GitOrigin-RevId: f1ac63cf47bb41bd3f3603e38a50ed43c9f03650
This commit is contained in:
parent
4d564d5cf1
commit
3be4883649
2 changed files with 26 additions and 51 deletions
|
@ -1,34 +1,29 @@
|
|||
/* eslint-disable
|
||||
max-len,
|
||||
no-unused-vars,
|
||||
no-useless-escape,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
let EmailHelper
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const EMAIL_REGEXP = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\ ".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA -Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||
|
||||
module.exports = EmailHelper = {
|
||||
parseEmail(email) {
|
||||
if (email == null) {
|
||||
return null
|
||||
}
|
||||
if (email.length > 254) {
|
||||
return null
|
||||
}
|
||||
email = email.trim().toLowerCase()
|
||||
|
||||
const matched = email.match(EMAIL_REGEXP)
|
||||
if (matched == null || matched[0] == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return matched[0]
|
||||
}
|
||||
function getDomain(email) {
|
||||
email = parseEmail(email)
|
||||
return email ? email.split('@').pop() : null
|
||||
}
|
||||
|
||||
function parseEmail(email) {
|
||||
if (email == null) {
|
||||
return null
|
||||
}
|
||||
if (email.length > 254) {
|
||||
return null
|
||||
}
|
||||
email = email.trim().toLowerCase()
|
||||
|
||||
const matched = email.match(EMAIL_REGEXP)
|
||||
if (matched == null || matched[0] == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return matched[0]
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getDomain,
|
||||
parseEmail
|
||||
}
|
||||
|
|
|
@ -17,24 +17,6 @@ const settings = require('settings-sharelatex')
|
|||
const request = require('request')
|
||||
const { promisifyAll } = require('../../util/promises')
|
||||
const NotificationsBuilder = require('../Notifications/NotificationsBuilder')
|
||||
const V1Api = require('../V1/V1Api')
|
||||
|
||||
function getInstitutionViaDomain(domain) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
V1Api.request(
|
||||
{
|
||||
timeout: 20 * 1000,
|
||||
uri: `api/v1/sharelatex/university_saml?hostname=${domain}`
|
||||
},
|
||||
function(error, response, body) {
|
||||
if (error) {
|
||||
reject(error)
|
||||
}
|
||||
resolve(body)
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const InstitutionsAPI = {
|
||||
getInstitutionAffiliations(institutionId, callback) {
|
||||
|
@ -51,8 +33,6 @@ const InstitutionsAPI = {
|
|||
)
|
||||
},
|
||||
|
||||
getInstitutionViaDomain,
|
||||
|
||||
getInstitutionLicences(institutionId, startDate, endDate, lag, callback) {
|
||||
if (callback == null) {
|
||||
callback = function(error, body) {}
|
||||
|
|
Loading…
Reference in a new issue