26 lines
1.0 KiB
Groovy
26 lines
1.0 KiB
Groovy
def 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,}))$'
|
|
|
|
|
|
def sourceIp = request.getLoginContext()['connection.HttpHeader.X-Real-IP'] ?: 'unknown'
|
|
def userAgent = request.getLoginContext()['connection.HttpHeader.user-agent'] ?: request.getLoginContext()['connection.HttpHeader.User-Agent'] ?: 'unknown'
|
|
|
|
if (inargs['cancel'] && inargs['cancel'] == 'cancel') {
|
|
response.setResult('cancel')
|
|
return
|
|
}
|
|
|
|
if ( inargs['continue'] && inargs['continue'] == 'continue' ) {
|
|
if (inargs['email'] && inargs['email'].matches(EMAIL_REGEXP)) {
|
|
response.setResult('verifyEmail')
|
|
return
|
|
} else {
|
|
LOG.warn("User attempted to bypass frontend emailvalidation with inavlid email: '${inargs['email']}', SourceIp=${sourceIp}, UserAgent='${userAgent}'")
|
|
request.getInArgs().setProperty('email', 'inavalid@email.org')
|
|
response.setResult('stay')
|
|
return
|
|
}
|
|
}
|
|
|
|
response.setResult('stay')
|
|
return
|