feat(auth): login, MFA and account screens
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
67cf62b536
commit
42892cb37f
10 files changed
+1226
-13
No files matched your search
@@ -47,6 +47,50 @@ export function tr(text) {
|
||||
return lead + out + trail;
|
||||
}
|
||||
|
||||
// The server speaks fixed English messages; the interface shows them in the
|
||||
// user's language. Unknown messages pass through as they came.
|
||||
const SERVER_MESSAGES = {
|
||||
'invalid credentials': 'Credenciais inválidas.',
|
||||
'too many attempts': 'Muitas tentativas.',
|
||||
'setup required': 'A configuração inicial ainda não foi concluída.',
|
||||
'invalid setup code': 'Código de configuração inválido.',
|
||||
'the last administrator must remain': 'O último administrador precisa continuar existindo.',
|
||||
'MFA is mandatory for administrators': 'O MFA é obrigatório para administradores.',
|
||||
'no enrollment in progress': 'Nenhum cadastro de MFA em andamento.',
|
||||
'username is already in use': 'Este nome de usuário já está em uso.',
|
||||
'not found': 'Não encontrado.',
|
||||
'recent authentication required': 'É preciso confirmar sua identidade de novo.',
|
||||
forbidden: 'Sem permissão para esta ação.',
|
||||
'internal error': 'Erro interno do serviço.',
|
||||
'authentication required': 'Sua sessão terminou. Entre de novo.',
|
||||
'invalid CSRF token': 'Sessão desatualizada. Recarregue a página.',
|
||||
'analysis failed': 'A análise falhou. Os detalhes ficam no log do servidor.',
|
||||
'password is too common': 'Esta senha é comum demais.',
|
||||
'password must not repeat a single character': 'A senha não pode repetir um único caractere.',
|
||||
'password must not be only digits': 'A senha não pode ter só dígitos.',
|
||||
'new password must differ from the current one': 'A nova senha precisa ser diferente da atual.',
|
||||
"username must not contain ':' or control characters": 'O nome de usuário não pode ter dois-pontos nem caracteres de controle.',
|
||||
'username must not start or end with a space': 'O nome de usuário não pode começar nem terminar com espaço.',
|
||||
'token expiry must be in the future and within 365 days': 'A validade do token precisa estar no futuro e em até 365 dias.',
|
||||
'too many API tokens': 'Esta conta já tem tokens de API demais.',
|
||||
};
|
||||
const SERVER_PATTERNS = [
|
||||
[/^password must be at least (\d+) characters$/, 'A senha precisa ter pelo menos {n} caracteres.'],
|
||||
[/^password must be at most (\d+) bytes$/, 'A senha pode ter no máximo {n} bytes.'],
|
||||
[/^username must have 1 to (\d+) characters$/, 'O nome de usuário precisa ter de 1 a {n} caracteres.'],
|
||||
[/^token name must have 1 to (\d+) characters, without control characters$/, 'O nome do token precisa ter de 1 a {n} caracteres, sem caracteres de controle.'],
|
||||
];
|
||||
|
||||
export function serverMessage(raw) {
|
||||
const known = SERVER_MESSAGES[raw];
|
||||
if (known) return tr(known);
|
||||
for (const [re, template] of SERVER_PATTERNS) {
|
||||
const match = String(raw).match(re);
|
||||
if (match) return tr(template).replace('{n}', match[1]);
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
const original = new WeakMap();
|
||||
let observer = null;
|
||||
|
||||
|
||||
Reference in new issue
Block a user