Merge branch 'fix/registration-backend-interactor-fix' into 'develop'

Fix #750 , fix error messages and captcha resetting

Closes #750

See merge request pleroma/pleroma-fe!1042
This commit is contained in:
Shpuld Shpludson 2020-01-14 13:45:00 +00:00
commit dac263e224
5 changed files with 18 additions and 7 deletions

View file

@ -5,9 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
### Changed ### Changed
- Captcha now resets on failed registrations
- Notifications column now cleans itself up to optimize performance when tab is left open for a long time - Notifications column now cleans itself up to optimize performance when tab is left open for a long time
### Fixed ### Fixed
- Single notifications left unread when hitting read on another device/tab - Single notifications left unread when hitting read on another device/tab
- Registration fixed
## [1.1.8] - 2020-01-10 ## [1.1.8] - 2020-01-10
### Added ### Added

View file

@ -63,7 +63,8 @@ const registration = {
await this.signUp(this.user) await this.signUp(this.user)
this.$router.push({ name: 'friends' }) this.$router.push({ name: 'friends' })
} catch (error) { } catch (error) {
console.warn('Registration failed: ' + error) console.warn('Registration failed: ', error)
this.setCaptcha()
} }
} }
}, },

View file

@ -170,7 +170,7 @@
<label <label
class="form--label" class="form--label"
for="captcha-label" for="captcha-label"
>{{ $t('captcha') }}</label> >{{ $t('registration.captcha') }}</label>
<template v-if="['kocaptcha', 'native'].includes(captcha.type)"> <template v-if="['kocaptcha', 'native'].includes(captcha.type)">
<img <img

View file

@ -401,7 +401,9 @@ const users = {
let rootState = store.rootState let rootState = store.rootState
try { try {
let data = await rootState.api.backendInteractor.register({ ...userInfo }) let data = await rootState.api.backendInteractor.register(
{ params: { ...userInfo } }
)
store.commit('signUpSuccess') store.commit('signUpSuccess')
store.commit('setToken', data.access_token) store.commit('setToken', data.access_token)
store.dispatch('loginUser', data.access_token) store.dispatch('loginUser', data.access_token)

View file

@ -32,12 +32,18 @@ export class RegistrationError extends Error {
} }
if (typeof error === 'object') { if (typeof error === 'object') {
const errorContents = JSON.parse(error.error)
// keys will have the property that has the error, for example 'ap_id',
// 'email' or 'captcha', the value will be an array of its error
// like "ap_id": ["has been taken"] or "captcha": ["Invalid CAPTCHA"]
// replace ap_id with username // replace ap_id with username
if (error.ap_id) { if (errorContents.ap_id) {
error.username = error.ap_id errorContents.username = errorContents.ap_id
delete error.ap_id delete errorContents.ap_id
} }
this.message = humanizeErrors(error)
this.message = humanizeErrors(errorContents)
} else { } else {
this.message = error this.message = error
} }