Added user verif method and refactored some indents

This commit is contained in:
Alexis
2020-12-27 19:08:09 +01:00
parent da73fa5241
commit 32c17407e2

View File

@@ -151,6 +151,37 @@ class UserRepository {
}) })
} }
verifyUser(token) {
return new Promise((resolve, reject) => {
model.forge()
.where({ 'verification_token' : token })
.fetch()
.then(v => {
bookshelf.transaction(t => {
return v.save({
'verification_token': null,
'verified': 1,
}, {
method: 'update',
transacting: t
})
})
.then(v => {
resolve({
"message": "Insérez ici une future redirection vers le client.",
"code": 202,
})
})
})
.catch(() => {
reject({
"message": "Le lien de vérification ne semble pas correct.",
"code": 404
})
})
});
}
// Log user with an email address and a password // Log user with an email address and a password
logUser(mail, password) { logUser(mail, password) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {