fix #9, better error during registration

This commit is contained in:
les
2019-09-05 13:31:14 +02:00
parent 1bc8a83cf8
commit b755f940d7
4 changed files with 10 additions and 8 deletions

View File

@@ -160,8 +160,9 @@ Adding this link to your feed reader will keep you up to date.`,
remove_account_confirm: 'You are about to permanently delete your account', remove_account_confirm: 'You are about to permanently delete your account',
}, },
err: { error: {
register_error: 'Error during registration' nick_taken: 'This nickname is already used',
email_taken: 'This email is already used'
}, },
ordinal: { ordinal: {

View File

@@ -165,8 +165,9 @@ export default {
remove_account_confirm: 'Stai per eliminare definitivamente il tuo account', remove_account_confirm: 'Stai per eliminare definitivamente il tuo account',
}, },
err: { error: {
register_error: 'Errore nella registrazione' nick_taken: 'Questo nick è già presente',
email_taken: 'Questa email è già registrata'
}, },
ordinal: { ordinal: {

View File

@@ -66,10 +66,10 @@ export default {
}) })
this.$router.replace("/") this.$router.replace("/")
} catch (e) { } catch (e) {
const error = get(e, 'e.response.data.errors[0].message', String(e)) const error = get(e, 'response.data.errors[0].message', String(e))
Message({ Message({
showClose: true, showClose: true,
message: this.$t('register.error') + this.$t(error), message: this.$t(error),
type: 'error' type: 'error'
}) })
} }

View File

@@ -9,14 +9,14 @@ module.exports = (sequelize, DataTypes) => {
const user = sequelize.define('user', { const user = sequelize.define('user', {
username: { username: {
type: DataTypes.STRING, type: DataTypes.STRING,
unique: true, unique: { msg: 'error.username_taken' },
index: true, index: true,
allowNull: false allowNull: false
}, },
display_name: DataTypes.STRING, display_name: DataTypes.STRING,
email: { email: {
type: DataTypes.STRING, type: DataTypes.STRING,
unique: true, unique: { msg: 'error.email_taken' },
index: true, index: true,
allowNull: false allowNull: false
}, },