Skip to content

Commit 8151bdd

Browse files
committed
fix(persona): reference model using getModel method
this._model is null initially, so instead make use of this.getModel()
1 parent 9f19ab0 commit 8151bdd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Persona.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class Persona {
483483
await callback(payload)
484484
}
485485

486-
const user = await this._model.create(payload)
486+
const user = await this.getModel().create(payload)
487487

488488
/**
489489
* Get email verification token for the user

test/persona.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -735,4 +735,18 @@ test.group('Persona', (group) => {
735735
const token1 = await this.persona.generateToken(user1, 'email')
736736
assert.notEqual(token, token1)
737737
})
738+
739+
test('use custom registration rules', async (assert) => {
740+
this.persona.registerationRules = function () {
741+
return {
742+
username: 'required'
743+
}
744+
}
745+
746+
await this.persona.register({ username: 'virk', email: '[email protected]' })
747+
const users = await getUser().all()
748+
749+
assert.equal(users.size(), 1)
750+
assert.equal(users.first().email, '[email protected]')
751+
})
738752
})

0 commit comments

Comments
 (0)