ee9f63a161
bugfix wip flow fix cleaning clean
38 lines
850 B
JavaScript
38 lines
850 B
JavaScript
import * as ACTIONS from 'constants/action_types';
|
|
import { Lbryio } from 'lbryinc';
|
|
|
|
export function doGenerateAuthToken(installationId) {
|
|
return dispatch => {
|
|
dispatch({
|
|
type: ACTIONS.GENERATE_AUTH_TOKEN_STARTED,
|
|
});
|
|
|
|
Lbryio.call(
|
|
'user',
|
|
'new',
|
|
{
|
|
auth_token: '',
|
|
language: 'en',
|
|
app_id: installationId,
|
|
},
|
|
'post'
|
|
)
|
|
.then(response => {
|
|
if (!response.auth_token) {
|
|
dispatch({
|
|
type: ACTIONS.GENERATE_AUTH_TOKEN_FAILURE,
|
|
});
|
|
} else {
|
|
dispatch({
|
|
type: ACTIONS.GENERATE_AUTH_TOKEN_SUCCESS,
|
|
data: { authToken: response.auth_token },
|
|
});
|
|
}
|
|
})
|
|
.catch(() => {
|
|
dispatch({
|
|
type: ACTIONS.GENERATE_AUTH_TOKEN_FAILURE,
|
|
});
|
|
});
|
|
};
|
|
}
|