pass uid along with verify email
This commit is contained in:
Родитель
f9f6b59eaa
Коммит
71b3e186aa
|
@ -5,10 +5,6 @@ var isA = Hapi.types
|
|||
|
||||
const HEX_STRING = /^(?:[a-fA-F0-9]{2})+$/
|
||||
|
||||
|
||||
config.smtp.subject = 'PiCL email verification'
|
||||
config.smtp.sender = config.smtp.sender || config.smtp.user
|
||||
|
||||
var mailer = new Mailer(config.smtp)
|
||||
|
||||
var server = Hapi.createServer(config.smtp.listen.host, config.smtp.listen.port)
|
||||
|
@ -22,12 +18,13 @@ server.route(
|
|||
handler: function (request) {
|
||||
var reply = request.reply.bind(request)
|
||||
mailer
|
||||
.sendVerifyCode(Buffer(request.payload.email, 'hex').toString(), request.payload.code)
|
||||
.sendVerifyCode(Buffer(request.payload.email, 'hex').toString(), request.payload.code, request.payload.uid)
|
||||
.done(reply, reply)
|
||||
},
|
||||
validate: {
|
||||
payload: {
|
||||
email: isA.String().regex(HEX_STRING).required(),
|
||||
uid: isA.String().max(64).required(),
|
||||
code: isA.String().required()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@ Mailer.prototype.send = function (message) {
|
|||
return d.promise
|
||||
}
|
||||
|
||||
Mailer.prototype.sendVerifyCode = function (email, code) {
|
||||
Mailer.prototype.sendVerifyCode = function (email, code, uid) {
|
||||
var template = templates.verify
|
||||
var link = this.verification_url + '?code=' + code
|
||||
var link = this.verification_url + '?uid=' + uid + '&code=' + code
|
||||
var reportLink = this.report_url
|
||||
|
||||
var values = {
|
||||
|
|
|
@ -61,7 +61,7 @@ module.exports = function (crypto, P, db, mailer) {
|
|||
}
|
||||
|
||||
RecoveryEmail.prototype.sendVerifyCode = function () {
|
||||
return mailer.sendVerifyCode(Buffer(this.email, 'hex').toString('utf8'), this.code)
|
||||
return mailer.sendVerifyCode(Buffer(this.email, 'hex').toString('utf8'), this.code, this.uid)
|
||||
}
|
||||
|
||||
RecoveryEmail.prototype.verify = function (code) {
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
module.exports = function (crypto, error, isA, serverPublicKey, bridge) {
|
||||
|
||||
const HEX_STRING = /^(?:[a-fA-F0-9]{2})+$/
|
||||
|
||||
var routes = [
|
||||
{
|
||||
method: 'GET',
|
||||
|
@ -59,14 +61,20 @@ module.exports = function (crypto, error, isA, serverPublicKey, bridge) {
|
|||
handler: {
|
||||
proxy: {
|
||||
mapUri: function (request, next) {
|
||||
return next(null, bridge.url + '/verify_email')
|
||||
return next(null, bridge.url + request.raw.req.url)
|
||||
},
|
||||
passThrough: true,
|
||||
xforward: true
|
||||
}
|
||||
},
|
||||
validate: {
|
||||
query: {
|
||||
code: isA.String().regex(HEX_STRING).required(),
|
||||
uid: isA.String().max(64).required()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
return routes
|
||||
|
|
Загрузка…
Ссылка в новой задаче