Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
feat(server): Log the service and reason parameters for `/account…
Browse files Browse the repository at this point in the history
…/login`.

This is the first step to determine the volume of notificatione mails that will be sent.

issue #875
  • Loading branch information
Shane Tomlinson committed May 20, 2015
1 parent ec669ce commit fa7d1bd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/api.md
Expand Up @@ -272,6 +272,8 @@ ___Parameters___

* email - the primary email for this account
* authPW - the PBKDF2/HKDF stretched password as a hex string
* service - (optional) opaque alphanumeric token to be included in verification links
* reason - (optional) alphanumeric string indicating the reason for establishing a new session; may be "login" (the default) or "reconnect"

### Request

Expand Down
1 change: 1 addition & 0 deletions lib/log.js
Expand Up @@ -85,6 +85,7 @@ Lug.prototype.summary = function (request, response) {
request.auth.credentials.uid :
payload.uid || query.uid || '00'
line.service = payload.service || query.service
line.reason = payload.reason || query.reason
line.redirectTo = payload.redirectTo || query.redirectTo
line.keys = query.keys
line.email = payload.email || query.email
Expand Down
4 changes: 3 additions & 1 deletion lib/routes/account.js
Expand Up @@ -200,7 +200,9 @@ module.exports = function (
validate: {
payload: {
email: validators.email().required(),
authPW: isA.string().min(64).max(64).regex(HEX_STRING).required()
authPW: isA.string().min(64).max(64).regex(HEX_STRING).required(),
service: isA.string().max(16).alphanum().optional(),
reason: isA.string().max(16).optional()
}
},
response: {
Expand Down
4 changes: 3 additions & 1 deletion test/client/api.js
Expand Up @@ -120,7 +120,9 @@ ClientApi.prototype.accountLogin = function (email, authPW, opts) {
null,
{
email: email,
authPW: authPW.toString('hex')
authPW: authPW.toString('hex'),
service: opts.service || undefined,
reason: opts.reason || undefined
}
)
}
Expand Down
18 changes: 18 additions & 0 deletions test/remote/account_login_tests.js
Expand Up @@ -95,6 +95,24 @@ TestServer.start(config)
}
)

test(
'accepts a `reason` and `service`',
function (t) {
var email = server.uniqueEmail()
var password = 'abcdef'
return Client.createAndVerify(config.publicUrl, email, password, server.mailbox)
.then(
function (c) {
return Client.login(config.publicUrl, email, password, { service: 'sync', reason: 'signin' })
}
)
.then(
function (c) {
}
)
}
)

test(
'teardown',
function (t) {
Expand Down

0 comments on commit fa7d1bd

Please sign in to comment.