Use the http factory everywhere instead of the created element
This commit is contained in:
parent
50fe5d5ef2
commit
83983f167d
|
@ -1,4 +1,4 @@
|
|||
import {HTTP} from '@/http-common'
|
||||
import {HTTPFactory} from '@/http-common'
|
||||
import {ERROR_MESSAGE, LOADING} from '../mutation-types'
|
||||
import UserModel from '../../models/user'
|
||||
|
||||
|
@ -32,6 +32,7 @@ export default {
|
|||
actions: {
|
||||
// Logs a user in with a set of credentials.
|
||||
login(ctx, credentials) {
|
||||
const HTTP = HTTPFactory()
|
||||
ctx.commit(LOADING, true, {root: true})
|
||||
|
||||
// Delete an eventually preexisting old token
|
||||
|
@ -78,6 +79,7 @@ export default {
|
|||
// Registers a new user and logs them in.
|
||||
// Not sure if this is the right place to put the logic in, maybe a seperate js component would be better suited.
|
||||
register(ctx, credentials) {
|
||||
const HTTP = HTTPFactory()
|
||||
return HTTP.post('register', {
|
||||
username: credentials.username,
|
||||
email: credentials.email,
|
||||
|
@ -98,6 +100,7 @@ export default {
|
|||
},
|
||||
|
||||
linkShareAuth(ctx, hash) {
|
||||
const HTTP = HTTPFactory()
|
||||
return HTTP.post('/shares/' + hash + '/auth')
|
||||
.then(r => {
|
||||
localStorage.setItem('token', r.data.token)
|
||||
|
@ -128,6 +131,7 @@ export default {
|
|||
},
|
||||
// Renews the api token and saves it to local storage
|
||||
renewToken(ctx) {
|
||||
const HTTP = HTTPFactory()
|
||||
if (!ctx.state.authenticated) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
import {mapState} from 'vuex'
|
||||
|
||||
import router from '../../router'
|
||||
import {HTTP} from '@/http-common'
|
||||
import {HTTPFactory} from '@/http-common'
|
||||
import message from '../../message'
|
||||
import {ERROR_MESSAGE, LOADING} from '@/store/mutation-types'
|
||||
import legal from '../../components/misc/legal'
|
||||
|
@ -94,6 +94,7 @@ export default {
|
|||
}
|
||||
},
|
||||
beforeMount() {
|
||||
const HTTP = HTTPFactory()
|
||||
// Try to verify the email
|
||||
// FIXME: Why is this here? Can we find a better place for this?
|
||||
let emailVerifyToken = localStorage.getItem('emailConfirmToken')
|
||||
|
|
Reference in New Issue