Created
November 7, 2017 18:50
-
-
Save brunokunace/9673a99dfa36c69bf9ec0a84e3f6ecc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http from 'src/app/infra/services/http' | |
import store from 'src/app/infra/store' | |
import { register, unRegister, userData } from 'src/app/modules/auth/services' | |
/** | |
* @param {Object} credentials | |
* @param {boolean} remember | |
* @param {Function} success | |
*/ | |
export const login = (credentials, remember, success) => { | |
http | |
.post('/auth/login', credentials) | |
.then((response) => { | |
const token = response.data.access_token | |
register(token, remember, success) | |
}) | |
.then(() => | |
http | |
.get('/profile/me') | |
.then((response) => { | |
const user = response.data.data.attributes | |
userData(user) | |
}) | |
) | |
} | |
/** | |
* @param {Function} success | |
*/ | |
export const logout = (success) => { | |
unRegister(success) | |
.then(() => { | |
http.post('/auth/logout', store.getters.getAuthUser, {noLoading: true, requestId: ''}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment