Skip to content

Commit

Permalink
Fix enrollment:complete event in polling mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dafortune committed Aug 10, 2017
1 parent 8a80441 commit 07729c3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@

**Fix**
- Bump dependencies versions (no breaking changes) [\#37](https://github.com/auth0/auth0-guardian.js/pull/37) ([dafortune](https://github.com/dafortune)).

# [v1.2.1](https://github.com/auth0/auth0-guardian.js/tree/v1.1.1) (2017-06-13)
[Full Changelog](https://github.com/auth0/auth0-guardian.js/compare/v1.2.1...v1.2.0)

**Fix**
- Fix enrollment:complete event in polling mode [\#37](https://github.com/auth0/auth0-guardian.js/pull/38) ([dafortune](https://github.com/dafortune)).
3 changes: 2 additions & 1 deletion lib/utils/polling_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ pollingClient.prototype.emitEvents = function emitEvents(err, oldState, newState
}

if (oldState && oldState.state === 'pending' &&
!oldState.enrollment && newState.enrollment) {
(!oldState.enrollment || oldState.enrollment.available_methods.length === 0) &&
(newState.enrollment && newState.enrollment.available_methods.length > 0)) {
self.hub.emit('enrollment:confirmed', object.toCamelKeys({
device_account: newState.enrollment,
tx_id: newState.id
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth0-guardian-js",
"version": "1.2.0",
"version": "1.2.1",
"description": "Interface",
"main": "index.js",
"directories": {
Expand Down Expand Up @@ -33,7 +33,7 @@
"webpack": "^1.13.2"
},
"scripts": {
"test": "npm run eslint && mocha --recursive test",
"test": "mocha --recursive test",
"build": "webpack --config webpack.config.js",
"build:clean": "rm -rf ./dist && mkdir dist",
"dist": "npm run build:clean && npm run build",
Expand Down
34 changes: 23 additions & 11 deletions test/utils/polling_client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,16 @@ describe('utils/polling_client', function () {
state: 'pending',
enrollment: {
id: 'dev_123',
test: 'test'
test: 'test',
available_methods: ['sms']
}
},
events: [
{
name: 'enrollment:confirmed',
payload: {
deviceAccount: {
availableMethods: ['sms'],
id: 'dev_123',
test: 'test'
},
Expand All @@ -257,7 +259,8 @@ describe('utils/polling_client', function () {
state: 'accepted',
enrollment: {
id: 'dev_123',
test: 'test'
test: 'test',
available_methods: ['push']
},
token: '123.123.1234'
},
Expand All @@ -267,7 +270,8 @@ describe('utils/polling_client', function () {
payload: {
deviceAccount: {
id: 'dev_123',
test: 'test'
test: 'test',
availableMethods: ['push']
},
txId: 'tx_1234'
}
Expand Down Expand Up @@ -296,7 +300,8 @@ describe('utils/polling_client', function () {
state: 'rejected',
enrollment: {
id: 'dev_123',
test: 'test'
test: 'test',
available_methods: ['totp']
}
},
events: [
Expand All @@ -305,7 +310,8 @@ describe('utils/polling_client', function () {
payload: {
deviceAccount: {
id: 'dev_123',
test: 'test'
test: 'test',
availableMethods: ['totp']
},
txId: 'tx_1234'
}
Expand All @@ -328,15 +334,17 @@ describe('utils/polling_client', function () {
state: 'pending',
enrollment: {
id: 'dev_123',
test: 'test'
test: 'test',
available_methods: []
}
},
transitionState: {
id: 'tx_1234',
state: 'rejected',
enrollment: {
id: 'dev_123',
test: 'test'
test: 'test',
available_methods: []
}
},
events: [
Expand All @@ -358,15 +366,17 @@ describe('utils/polling_client', function () {
state: 'pending',
enrollment: {
id: 'dev_123',
test: 'test'
test: 'test',
available_methods: []
}
},
transitionState: {
id: 'tx_1234',
state: 'accepted',
enrollment: {
id: 'dev_123',
test: 'test'
test: 'test',
available_methods: []
},
token: '123.123.1234'
},
Expand Down Expand Up @@ -395,7 +405,8 @@ describe('utils/polling_client', function () {
state: 'accepted',
enrollment: {
id: 'dev_123',
test: 'test'
test: 'test',
available_methods: ['totp']
},
token: '123.123.1234'
},
Expand All @@ -405,7 +416,8 @@ describe('utils/polling_client', function () {
payload: {
deviceAccount: {
id: 'dev_123',
test: 'test'
test: 'test',
availableMethods: ['totp']
},
txId: 'tx_1234'
}
Expand Down

0 comments on commit 07729c3

Please sign in to comment.