1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-17 07:45:52 +01:00
verdaccio/test/unit/webui/components/store/login.js
ayusharma 5c95551e8f refactor: unit tests and api service
refactor: fixes login api success call

refactor: fixes login respose for success case
2018-06-30 12:22:07 +02:00

21 lines
492 B
JavaScript

/**
* API mock for login endpoint
* @param {object} config configuration of api call
* @returns {promise}
*/
export default function(config) {
return new Promise((resolve, reject) => {
const body = JSON.parse(config.body);
if (body.username === 'sam' && body.password === '1234') {
resolve({
username: 'sam',
token: 'TEST_TOKEN'
});
} else {
reject({
error: 'bad username/password, access denied'
});
}
});
}