feat(app): add evaluation history, bot control panel, simulation visualizer, and vendored signalr_core
This commit is contained in:
@@ -19,7 +19,6 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
super(AuthInitial()) {
|
||||
on<CheckAuthStatus>(_onCheckAuthStatus);
|
||||
on<LoginRequested>(_onLoginRequested);
|
||||
on<RegisterRequested>(_onRegisterRequested);
|
||||
on<LogoutRequested>(_onLogoutRequested);
|
||||
}
|
||||
|
||||
@@ -44,16 +43,6 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onRegisterRequested(RegisterRequested event, Emitter<AuthState> emit) async {
|
||||
emit(AuthLoading());
|
||||
try {
|
||||
final user = await repository.register(event.email, event.password, event.fullName);
|
||||
emit(Authenticated(user));
|
||||
} catch (e) {
|
||||
emit(AuthFailure(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLogoutRequested(LogoutRequested event, Emitter<AuthState> emit) async {
|
||||
await repository.logout();
|
||||
emit(Unauthenticated());
|
||||
|
||||
@@ -19,15 +19,4 @@ class LoginRequested extends AuthEvent {
|
||||
List<Object?> get props => [email, password];
|
||||
}
|
||||
|
||||
class RegisterRequested extends AuthEvent {
|
||||
final String email;
|
||||
final String password;
|
||||
final String fullName;
|
||||
|
||||
const RegisterRequested(this.email, this.password, this.fullName);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [email, password, fullName];
|
||||
}
|
||||
|
||||
class LogoutRequested extends AuthEvent {}
|
||||
|
||||
@@ -36,11 +36,16 @@ class AuthRepository {
|
||||
'password': password,
|
||||
});
|
||||
if (res.statusCode == 200 && res.data != null) {
|
||||
final token = res.data['token']?.toString() ?? '';
|
||||
|
||||
if (res.data['requiresPasswordChange'] == true) {
|
||||
// The backend already issues a valid JWT even when a password change is required, so it must be
|
||||
// persisted here: the subsequent change-initial-password call is an [Authorize]-protected endpoint
|
||||
// and has no other way to authenticate itself.
|
||||
await storageService.saveToken(token);
|
||||
throw RequiresPasswordChangeException(res.data['userId']?.toString() ?? '');
|
||||
}
|
||||
|
||||
final token = res.data['token']?.toString() ?? '';
|
||||
final user = UserModel.fromJson(res.data, token: token);
|
||||
await storageService.saveToken(token);
|
||||
await storageService.saveUserEmail(user.email);
|
||||
@@ -50,23 +55,6 @@ class AuthRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<UserModel> register(String email, String password, String fullName) async {
|
||||
final res = await apiClient.post('/api/v1/auth/register', data: {
|
||||
'email': email,
|
||||
'password': password,
|
||||
'fullName': fullName,
|
||||
});
|
||||
if (res.statusCode == 200 && res.data != null) {
|
||||
final token = res.data['token']?.toString() ?? '';
|
||||
final user = UserModel.fromJson(res.data, token: token);
|
||||
await storageService.saveToken(token);
|
||||
await storageService.saveUserEmail(user.email);
|
||||
return user;
|
||||
} else {
|
||||
throw Exception('Registrierung fehlgeschlagen');
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> changeInitialPassword(String userId, String newPassword) async {
|
||||
final res = await apiClient.post('/api/v1/auth/change-initial-password', data: {
|
||||
'userId': userId,
|
||||
|
||||
@@ -20,6 +20,8 @@ class _ChangeInitialPasswordScreenState extends State<ChangeInitialPasswordScree
|
||||
final _passwordController = TextEditingController();
|
||||
final _confirmPasswordController = TextEditingController();
|
||||
bool _isLoading = false;
|
||||
bool _obscurePassword = true;
|
||||
bool _obscureConfirmPassword = true;
|
||||
|
||||
void _onChangePassword() async {
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
@@ -96,15 +98,29 @@ class _ChangeInitialPasswordScreenState extends State<ChangeInitialPasswordScree
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(labelText: 'Neues Passwort', prefixIcon: Icon(Icons.lock)),
|
||||
obscureText: _obscurePassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Neues Passwort',
|
||||
prefixIcon: const Icon(Icons.lock),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined),
|
||||
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
|
||||
),
|
||||
),
|
||||
validator: (v) => v == null || v.length < 6 ? 'Passwort muss mindestens 6 Zeichen lang sein' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _confirmPasswordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(labelText: 'Passwort bestätigen', prefixIcon: Icon(Icons.lock_outline)),
|
||||
obscureText: _obscureConfirmPassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Passwort bestätigen',
|
||||
prefixIcon: const Icon(Icons.lock_outline),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscureConfirmPassword ? Icons.visibility_outlined : Icons.visibility_off_outlined),
|
||||
onPressed: () => setState(() => _obscureConfirmPassword = !_obscureConfirmPassword),
|
||||
),
|
||||
),
|
||||
validator: (v) => v != _passwordController.text ? 'Passwörter stimmen nicht überein' : null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
@@ -16,6 +16,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
bool _obscurePassword = true;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -75,8 +76,15 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(labelText: 'Passwort', prefixIcon: Icon(Icons.lock_outline)),
|
||||
obscureText: _obscurePassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Passwort',
|
||||
prefixIcon: const Icon(Icons.lock_outline),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined),
|
||||
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
|
||||
),
|
||||
),
|
||||
validator: (v) => v == null || v.isEmpty ? 'Passwort erforderlich' : null,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
@@ -100,6 +108,12 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"Konten werden ausschließlich vom Administrator angelegt.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: AppTheme.textMuted, fontSize: 11),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
import '../bloc/auth_bloc.dart';
|
||||
|
||||
/// User registration screen widget.
|
||||
class RegisterScreen extends StatefulWidget {
|
||||
const RegisterScreen({super.key});
|
||||
|
||||
@override
|
||||
State<RegisterScreen> createState() => _RegisterScreenState();
|
||||
}
|
||||
|
||||
class _RegisterScreenState extends State<RegisterScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _nameController = TextEditingController();
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
void _submit() {
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
context.read<AuthBloc>().add(RegisterRequested(
|
||||
_emailController.text.trim(),
|
||||
_passwordController.text.trim(),
|
||||
_nameController.text.trim(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Konto Registrieren')),
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 420),
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.cardSurface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppTheme.glassBorder),
|
||||
),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.person_add_outlined, size: 48, color: AppTheme.primaryEmerald),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Neues Konto erstellen',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(labelText: 'Vollständiger Name', prefixIcon: Icon(Icons.person_outline)),
|
||||
validator: (v) => v == null || v.isEmpty ? 'Name erforderlich' : null,
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: const InputDecoration(labelText: 'E-Mail', prefixIcon: Icon(Icons.email_outlined)),
|
||||
validator: (v) => v == null || !v.contains('@') ? 'Gültige E-Mail erforderlich' : null,
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(labelText: 'Passwort', prefixIcon: Icon(Icons.lock_outline)),
|
||||
validator: (v) => v == null || v.length < 6 ? 'Mind. 6 Zeichen' : null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton(
|
||||
onPressed: _submit,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primaryEmerald,
|
||||
foregroundColor: Colors.black,
|
||||
),
|
||||
child: const Text('Registrieren', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user