Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @action doLogin = () => {
- const {username, password} = this.loginFormValues;
- this.pending = true;
- return Api({
- method: 'POST',
- baseURL: Routes.API,
- url: `/${Routes.OAUTH}/${Routes.TOKEN}`,
- headers: {
- 'Content-type': 'application/x-www-form-urlencoded',
- },
- data: {
- grant_type: 'password',
- username: username,
- password: password,
- client_id: 'web_client',
- client_secret: 'secret',
- }
- }).then(response => {
- action((data = response.data) => {
- localStorage.setItem('accessToken', data.access_token);
- localStorage.setItem('refreshToken', data.refresh_token);
- this.error = undefined;
- })
- }).catch(error => {
- action((responseError = createErrorFromResponse(error.response)) => {
- this.loginError = responseError;
- })
- }).then(() => {
- this.pending = false;
- })
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement