* Add note to public page

* Add project chooser on public view

* Optimize loading order

So much nicer to use now

Closes #298

* Fix the private project switcher too

* Add transition to public view

* Prevent project switching if youre already on that project

* [WIP] Add reset password form

* Add request password reset page

* Add jwt-payload util

* Install base-64

* Fix test typing

* Add new errors to translations

* Finish reset password flow

* Fix foreground color on v-notice

* Fix tests

* Allow code in translateError + render project error translated on login

* Remove wrong reference to error component

* Render project key if name is unknown

* Fix date-fns version

* Fix tests
This commit is contained in:
Rijk van Zanten
2020-04-09 19:06:15 -04:00
committed by GitHub
parent 153eaec78a
commit 7485a97a3b
39 changed files with 710 additions and 244 deletions

View File

@@ -126,6 +126,28 @@
"help_and_docs": "Help & Docs",
"errors": {
"11": "Can't Reach Database",
"100": "Incorrect Email/Password",
"101": "Logged-out from Inactivity",
"102": "Logged-out from Inactivity",
"103": "User Suspended",
"105": "Reset link expired",
"106": "Incorrect Email/Password",
"107": "User Not Found",
"111": "Enter One-Time Password",
"112": "Wrong One-Time Password",
"114": "Incorrect Email/Password",
"115": "SSO is not allowed when 2FA is enabled",
"503": "Email couldn't be sent. Please verify the API's configuration",
"-1": "Couldn't Reach API"
},
"unexpected_error": "An unexpected error occured",
"password_reset_sent": "We've sent you a secure link to reset your password",
"password_reset_successful": "Password successfully reset",
"about_directus": "About Directus",
"activity_log": "Activity Log",
@@ -319,20 +341,6 @@
"environment": "Environment",
"equal_to": "Equal to",
"error_unknown": "Unknown error. Try again later.",
"errors": {
"11": "Can Not Reach Database",
"100": "Incorrect Email/Password",
"101": "Logged-out from Inactivity",
"102": "Logged-out from Inactivity",
"103": "User Suspended",
"106": "Incorrect Email/Password",
"107": "User Not Found",
"111": "Enter One-Time Password",
"112": "Wrong One-Time Password",
"114": "Incorrect Email/Password",
"115": "SSO is not allowed when 2FA is enabled",
"-1": "Couldn't Reach API"
},
"esc_cancel": "Escape will cancel and close the window.",
"event_count": "No Events | One Event | {count} Events",
"existing": "Existing",
@@ -499,8 +507,6 @@
"otp": "One-Time Password",
"password": "Password",
"password_reset_sending": "Sending email...",
"password_reset_sent": "If a valid user with this email address exists in Directus, we've sent you a secure link to reset your password.",
"password_reset_successful": "Password successfully reset.",
"permission_states": {
"always": "Always",
"create": "Create",

View File

@@ -1,6 +1,7 @@
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import { merge } from 'lodash';
import { RequestError } from '@/api';
import enUSBase from './en-US/index.json';
import enUSInterfaces from './en-US/interfaces.json';
@@ -100,3 +101,20 @@ export async function setLanguage(lang: Language): Promise<boolean> {
}
export default i18n;
export function translateAPIError(error: RequestError | number) {
const defaultMsg = i18n.t('unexpected_error');
let code = error;
if (typeof error !== 'number') {
code = error?.response?.data?.error?.code;
}
if (!error) return defaultMsg;
if (!code === undefined) return defaultMsg;
const key = `errors.${code}`;
const exists = i18n.te(key);
if (exists === false) return defaultMsg;
return i18n.t(key);
}