- Added email availability checker in API
This commit is contained in:
@@ -38,7 +38,7 @@ router.get('/', async (req, res) => {
|
||||
})
|
||||
|
||||
|
||||
// GET ONE FORM UUID ------------------
|
||||
// GET ONE FROM UUID ------------------
|
||||
const getUserByUUID = (uuid) => {
|
||||
return Users.getOneByUUID(uuid)
|
||||
.catch(err => {
|
||||
@@ -63,6 +63,31 @@ router.get('/:uuid/', async (req, res) => {
|
||||
})
|
||||
|
||||
|
||||
// CHECK IF MAIL IS AVAILABLE ------------------
|
||||
const checkIfEmailAvailable = (mail) => {
|
||||
return Users.checkIfEmailAvailable(mail)
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
throw err
|
||||
})
|
||||
}
|
||||
router.get('/available/:mail/', async (req, res) => {
|
||||
checkIfEmailAvailable(req.params.mail)
|
||||
.then(v => {
|
||||
res.setHeader('Content-Type', 'application/json;charset=utf-8')
|
||||
res.end(JSON.stringify(v))
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(err.code).send(JSON.stringify(
|
||||
{
|
||||
"error": err.message,
|
||||
"code": err.code
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// LOG A USER ------------------
|
||||
const logUser = (mail, password) => {
|
||||
return Users.logUser(mail, password)
|
||||
|
||||
Reference in New Issue
Block a user