Separate captcha into the backendInteractor

This commit is contained in:
Ekaterina Vaartis 2018-12-16 20:53:41 +03:00
parent 92de235f4e
commit a525df32c9
4 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -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)

View File

@ -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,

View File

@ -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,