fixed reset password
This commit is contained in:
@@ -3,12 +3,14 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
import 'package:flux/core/enums_and_consts/consts.dart';
|
||||
import 'package:flux/core/utils/app_message.dart';
|
||||
import 'package:flux/features/master_data/staff/data/staff_repository.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
part 'auth_state.dart';
|
||||
|
||||
class AuthCubit extends Cubit<AuthState> {
|
||||
final _supabase = GetIt.instance<SupabaseClient>();
|
||||
final _staffRepository = GetIt.instance<StaffRepository>();
|
||||
|
||||
AuthCubit() : super(const AuthState());
|
||||
|
||||
@@ -95,10 +97,7 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
);
|
||||
return;
|
||||
}
|
||||
await _supabase.auth.resetPasswordForEmail(
|
||||
email,
|
||||
redirectTo: resetPasswordUrl,
|
||||
);
|
||||
await _staffRepository.resetPassword(email);
|
||||
emit(
|
||||
state.copyWith(
|
||||
status: AuthStatus.pwResetSent,
|
||||
|
||||
@@ -128,6 +128,30 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
_submit(), // Se lo supporti nel tuo widget custom
|
||||
),
|
||||
|
||||
// Link "Dimenticato password?" solo in Login mode
|
||||
if (state.isLoginMode) ...[
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () => context
|
||||
.read<AuthCubit>()
|
||||
.requestPasswordReset(
|
||||
_emailController.text.trim(),
|
||||
),
|
||||
child: Text(
|
||||
context.l10n.authScreenForgotPassword,
|
||||
style: TextStyle(
|
||||
color: context.accent,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// --- BOTTONE PRINCIPALE ---
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/main.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
class SetPasswordScreen extends StatefulWidget {
|
||||
@@ -63,7 +64,7 @@ class _SetPasswordScreenState extends State<SetPasswordScreen> {
|
||||
setState(() => _isSessionReady = true);
|
||||
}
|
||||
} catch (e) {
|
||||
print("Errore ripristino manuale sessione: $e");
|
||||
debugPrint("Errore ripristino manuale sessione: $e");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +99,7 @@ class _SetPasswordScreenState extends State<SetPasswordScreen> {
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
context.go('/');
|
||||
}
|
||||
} on AuthException catch (e) {
|
||||
setState(() {
|
||||
|
||||
Reference in New Issue
Block a user