Login:
- Tema oscuro propio (_kBg, _kPanel, _kAccent) con gradiente top→bottom
- Toggle animado Cuenta local / Cloud con indicador deslizante
- Validación inline, checkbox "Mantener sesión", botón degradado h52
- Links "¿No tienes cuenta?" → /registro y /registro_cloud
Registro local (/registro):
- 7 campos: nombre, correo, teléfono, empresa, RUC, contraseña x2
- Indicador de fortaleza (4 criterios), SHA-256, snackbar + pop al éxito
Registro cloud (/registro_cloud) — flujo 3 pasos + OTP:
- Paso 1: POST /api/auth/pre-register, stepper animado
- Paso 2: OTP 6 dígitos, cooldown 60s, reenvío
- Paso 3: nombre empresa (normalizado a MAYUSCULAS_SNAKE), usuario, contraseña
- Pantalla "Creando" con LinearProgressIndicator y lista de 6 pasos animados
- Pantalla de éxito → pushNamedAndRemoveUntil('/login')
- timeout 120s en POST /api/auth/register (creación de tenant)
AuthService: preRegister(), verifyOtpRegistro(), register(), saveLocalSession()
pubspec: agrega crypto ^3.0.0 para SHA-256
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
57 lines
1.5 KiB
Dart
57 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PasswordStrengthIndicator extends StatelessWidget {
|
|
final String password;
|
|
|
|
const PasswordStrengthIndicator({Key? key, required this.password})
|
|
: super(key: key);
|
|
|
|
static int _score(String p) {
|
|
int s = 0;
|
|
if (p.length >= 8) s++;
|
|
if (p.contains(RegExp(r'[A-Z]'))) s++;
|
|
if (p.contains(RegExp(r'[0-9]'))) s++;
|
|
if (p.contains(RegExp(r'[!@#\$%^&*(),.?":{}|<>_\-]'))) s++;
|
|
return s;
|
|
}
|
|
|
|
static const _labels = ['Muy débil', 'Débil', 'Regular', 'Buena', 'Fuerte'];
|
|
static const _colors = [
|
|
Color(0xFF7B0000),
|
|
Color(0xFFB71C1C),
|
|
Color(0xFFE65100),
|
|
Color(0xFFF9A825),
|
|
Color(0xFF2E7D32),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (password.isEmpty) return const SizedBox.shrink();
|
|
final score = _score(password);
|
|
final fraction = (score + 1) / 5;
|
|
final color = _colors[score];
|
|
final label = _labels[score];
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const SizedBox(height: 6),
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(4),
|
|
child: LinearProgressIndicator(
|
|
value: fraction,
|
|
backgroundColor: const Color(0xFF1E4070),
|
|
valueColor: AlwaysStoppedAnimation<Color>(color),
|
|
minHeight: 5,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
label,
|
|
style: TextStyle(color: color, fontSize: 11),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|