Skip to content
Permalink
Browse files

Prevent normal registration of "Ephemeral Accountant" user

  • Loading branch information...
bkimminich committed Aug 26, 2019
1 parent dfbebd7 commit 3959262c6b8e704d51d63a77478b7072bb5ff2e2
Showing with 9 additions and 0 deletions.
  1. +2 −0 frontend/src/app/register/register.component.ts
  2. +7 −0 models/user.js
@@ -68,6 +68,8 @@ export class RegisterComponent implements OnInit {
if (err.error && err.error.errors && err.error.errors[0].message) {
const errorMessage = err.error.errors[0].message
this.error = errorMessage[0].toUpperCase() + errorMessage.slice(1)
} else {
this.error = err.error.errors[0]
}
}
)
@@ -2,6 +2,7 @@
const insecurity = require('../lib/insecurity')
const utils = require('../lib/utils')
const challenges = require('../data/datacache').challenges
const config = require('config')

module.exports = (sequelize, { STRING, BOOLEAN }) => {
const User = sequelize.define('User', {
@@ -57,5 +58,11 @@ module.exports = (sequelize, { STRING, BOOLEAN }) => {
}
}, { paranoid: true })

User.addHook('afterValidate', (user) => {
if (user.email && user.email.toLowerCase() === `acc0unt4nt@${config.get('application.domain')}`.toLowerCase()) {
return Promise.reject(new Error('Nice try, but this is not how the "Ephemeral Accountant" challenge works!'))
}
})

return User
}

0 comments on commit 3959262

Please sign in to comment.
You can’t perform that action at this time.