mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-18 06:02:57 +05:30
Ignore token for some guest-specific requests
This commit is contained in:
parent
4888b37047
commit
2301aff3d5
@ -9,7 +9,8 @@ const authentication = {
|
|||||||
}) {
|
}) {
|
||||||
return request.post(
|
return request.post(
|
||||||
'/api/authentication/login',
|
'/api/authentication/login',
|
||||||
{login, password, rememberMe}
|
{login, password, rememberMe},
|
||||||
|
{token: null}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -12,14 +12,16 @@ export default {
|
|||||||
}) {
|
}) {
|
||||||
return request.post(
|
return request.post(
|
||||||
'/api/signup',
|
'/api/signup',
|
||||||
{email, username, password, rePassword, rulesAgreement, lang, captcha}
|
{email, username, password, rePassword, rulesAgreement, lang, captcha},
|
||||||
|
{token: null}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
activate({key = ''}) {
|
activate({key = ''}) {
|
||||||
return request.post(
|
return request.post(
|
||||||
'/api/signup/confirm',
|
'/api/signup/confirm',
|
||||||
{key}
|
{key},
|
||||||
|
{token: null}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
73
tests/services/api/activate.test.js
Normal file
73
tests/services/api/activate.test.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import expect from 'unexpected';
|
||||||
|
import sinon from 'sinon';
|
||||||
|
|
||||||
|
import request from 'services/request';
|
||||||
|
import signup from 'services/api/signup';
|
||||||
|
|
||||||
|
describe('signup api', () => {
|
||||||
|
describe('#register', () => {
|
||||||
|
const params = {
|
||||||
|
email: 'email',
|
||||||
|
username: 'username',
|
||||||
|
password: 'password',
|
||||||
|
rePassword: 'rePassword',
|
||||||
|
rulesAgreement: false,
|
||||||
|
lang: 'lang',
|
||||||
|
captcha: 'captcha'
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
sinon.stub(request, 'post').named('request.post');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
request.post.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should post to register api', () => {
|
||||||
|
signup.register(params);
|
||||||
|
|
||||||
|
expect(request.post, 'to have a call satisfying', [
|
||||||
|
'/api/signup', params, {}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should disable any token', () => {
|
||||||
|
signup.register(params);
|
||||||
|
|
||||||
|
expect(request.post, 'to have a call satisfying', [
|
||||||
|
'/api/signup', params, {token: null}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#activate', () => {
|
||||||
|
const params = {
|
||||||
|
key: 'key'
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
sinon.stub(request, 'post').named('request.post');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
request.post.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should post to confirmation api', () => {
|
||||||
|
signup.activate(params);
|
||||||
|
|
||||||
|
expect(request.post, 'to have a call satisfying', [
|
||||||
|
'/api/signup/confirm', params, {}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should disable any token', () => {
|
||||||
|
signup.activate(params);
|
||||||
|
|
||||||
|
expect(request.post, 'to have a call satisfying', [
|
||||||
|
'/api/signup/confirm', params, {token: null}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -6,6 +6,38 @@ import authentication from 'services/api/authentication';
|
|||||||
import accounts from 'services/api/accounts';
|
import accounts from 'services/api/accounts';
|
||||||
|
|
||||||
describe('authentication api', () => {
|
describe('authentication api', () => {
|
||||||
|
describe('#login', () => {
|
||||||
|
const params = {
|
||||||
|
login: 'foo',
|
||||||
|
password: 'secret',
|
||||||
|
rememberMe: false
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
sinon.stub(request, 'post').named('request.post');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
request.post.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should post to login api', () => {
|
||||||
|
authentication.login(params);
|
||||||
|
|
||||||
|
expect(request.post, 'to have a call satisfying', [
|
||||||
|
'/api/authentication/login', params, {}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should disable any token', () => {
|
||||||
|
authentication.login(params);
|
||||||
|
|
||||||
|
expect(request.post, 'to have a call satisfying', [
|
||||||
|
'/api/authentication/login', params, {token: null}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#validateToken()', () => {
|
describe('#validateToken()', () => {
|
||||||
const validTokens = {token: 'foo', refreshToken: 'bar'};
|
const validTokens = {token: 'foo', refreshToken: 'bar'};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user