forked from AkkomaGang/akkoma-fe
Separate captcha into the backendInteractor
This commit is contained in:
parent
92de235f4e
commit
a525df32c9
4 changed files with 11 additions and 7 deletions
|
@ -31,12 +31,7 @@ const registration = {
|
||||||
this.$router.push('/main/all')
|
this.$router.push('/main/all')
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch("/api/pleroma/captcha")
|
this.getCaptcha().then(cpt => this.captcha = cpt)
|
||||||
.then(resp => resp.json())
|
|
||||||
.then(resp => {
|
|
||||||
// TODO: check for errors
|
|
||||||
this.captcha = resp
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
token () { return this.$route.params.token },
|
token () { return this.$route.params.token },
|
||||||
|
@ -49,7 +44,7 @@ const registration = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['signUp']),
|
...mapActions(['signUp', 'getCaptcha']),
|
||||||
async submit () {
|
async submit () {
|
||||||
this.user.nickname = this.user.username
|
this.user.nickname = this.user.username
|
||||||
this.user.token = this.token
|
this.user.token = this.token
|
||||||
|
|
|
@ -142,6 +142,10 @@ const users = {
|
||||||
throw Error(errors)
|
throw Error(errors)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async getCaptcha (store) {
|
||||||
|
return await store.rootState.api.backendInteractor.getCaptcha()
|
||||||
|
},
|
||||||
|
|
||||||
logout (store) {
|
logout (store) {
|
||||||
store.commit('clearCurrentUser')
|
store.commit('clearCurrentUser')
|
||||||
store.commit('setToken', false)
|
store.commit('setToken', false)
|
||||||
|
|
|
@ -167,6 +167,8 @@ const register = (params) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getCaptcha = () => fetch('/api/pleroma/captcha').then(resp => resp.json())
|
||||||
|
|
||||||
const authHeaders = (accessToken) => {
|
const authHeaders = (accessToken) => {
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
return { 'Authorization': `Bearer ${accessToken}` }
|
return { 'Authorization': `Bearer ${accessToken}` }
|
||||||
|
@ -496,6 +498,7 @@ const apiService = {
|
||||||
setUserMute,
|
setUserMute,
|
||||||
fetchMutes,
|
fetchMutes,
|
||||||
register,
|
register,
|
||||||
|
getCaptcha,
|
||||||
updateAvatar,
|
updateAvatar,
|
||||||
updateBg,
|
updateBg,
|
||||||
updateProfile,
|
updateProfile,
|
||||||
|
|
|
@ -71,6 +71,7 @@ const backendInteractorService = (credentials) => {
|
||||||
const fetchMutes = () => apiService.fetchMutes({credentials})
|
const fetchMutes = () => apiService.fetchMutes({credentials})
|
||||||
const fetchFollowRequests = () => apiService.fetchFollowRequests({credentials})
|
const fetchFollowRequests = () => apiService.fetchFollowRequests({credentials})
|
||||||
|
|
||||||
|
const getCaptcha = () => apiService.getCaptcha()
|
||||||
const register = (params) => apiService.register(params)
|
const register = (params) => apiService.register(params)
|
||||||
const updateAvatar = ({params}) => apiService.updateAvatar({credentials, params})
|
const updateAvatar = ({params}) => apiService.updateAvatar({credentials, params})
|
||||||
const updateBg = ({params}) => apiService.updateBg({credentials, params})
|
const updateBg = ({params}) => apiService.updateBg({credentials, params})
|
||||||
|
@ -100,6 +101,7 @@ const backendInteractorService = (credentials) => {
|
||||||
setUserMute,
|
setUserMute,
|
||||||
fetchMutes,
|
fetchMutes,
|
||||||
register,
|
register,
|
||||||
|
getCaptcha,
|
||||||
updateAvatar,
|
updateAvatar,
|
||||||
updateBg,
|
updateBg,
|
||||||
updateBanner,
|
updateBanner,
|
||||||
|
|
Loading…
Reference in a new issue