Skip to content

Commit 18889f0

Browse files
committed
formatting
1 parent 0880e1d commit 18889f0

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

packages/models/src/user/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ const confirmEmail = async function confirmEmail ({ token, email }) {
182182

183183
const user = await findUserByNameOrEmail(email);
184184

185-
if (!user) {
185+
if (!user || user.emailConfirmationToken !== token) {
186186
throw new ModelError('invalid email confirmation token', {
187187
type: 'ForbiddenError'
188188
});

tests/tests/004-users-test.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,22 +438,37 @@ describe('openSenseMap API Routes: /users', function () {
438438
});
439439

440440
it('should allow to refresh jwt using the refresh token', function () {
441-
return chakram.post(`${BASE_URL}/users/refresh-auth`, { 'token': refreshToken })
441+
return chakram
442+
.post(
443+
`${BASE_URL}/users/refresh-auth`,
444+
{ token: refreshToken }
445+
)
442446
.then(function (response) {
443447
expect(response).to.have.status(200);
444-
expect(response).to.have.header('content-type', 'application/json; charset=utf-8');
448+
expect(response).to.have.header(
449+
'content-type',
450+
'application/json; charset=utf-8'
451+
);
445452
expect(response.body.token).to.exist;
446453
expect(response.body.refreshToken).to.exist;
447454

448455
const jwt = response.body.token;
449456

450-
return chakram.get(`${BASE_URL}/users/me`, { headers: { 'Authorization': `Bearer ${jwt}` } });
457+
return chakram.get(`${BASE_URL}/users/me`, {
458+
headers: { Authorization: `Bearer ${jwt}` }
459+
});
451460
})
452461
.then(function (response) {
453462
expect(response).to.have.status(200);
454-
expect(response).to.have.header('content-type', 'application/json; charset=utf-8');
463+
expect(response).to.have.header(
464+
'content-type',
465+
'application/json; charset=utf-8'
466+
);
455467
expect(response).to.have.schema(getUserSchema);
456-
expect(response).to.comprise.of.json({ code: 'Ok', data: { me: { email: '[email protected]' } } });
468+
expect(response).to.comprise.of.json({
469+
code: 'Ok',
470+
data: { me: { email: '[email protected]' } }
471+
});
457472

458473
return chakram.wait();
459474
});

0 commit comments

Comments
 (0)