2017-12-01 20:04:01 +01:00
|
|
|
/**
|
|
|
|
* API mock for login endpoint
|
2017-12-02 13:34:42 +01:00
|
|
|
* @param {object} config configuration of api call
|
|
|
|
* @returns {promise}
|
2017-12-01 20:04:01 +01:00
|
|
|
*/
|
|
|
|
export default function(config) {
|
2018-06-29 01:15:54 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
2018-03-21 21:44:19 +01:00
|
|
|
const body = JSON.parse(config.body);
|
|
|
|
if (body.username === 'sam' && body.password === '1234') {
|
|
|
|
resolve({
|
2018-06-29 01:15:54 +02:00
|
|
|
username: 'sam',
|
|
|
|
token: 'TEST_TOKEN'
|
2018-03-21 21:44:19 +01:00
|
|
|
});
|
2017-12-01 20:04:01 +01:00
|
|
|
} else {
|
2018-06-29 01:15:54 +02:00
|
|
|
reject({
|
|
|
|
error: 'bad username/password, access denied'
|
|
|
|
});
|
2017-12-01 20:04:01 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|