feat(01-07): update pages with password reset navigation and deep linking
- Updated login page to navigate to /reset-password instead of placeholder - Added "Forgot Password?" link to signup page - Enhanced reset password confirmation page to extract token/email from URL parameters - Updated update password page to handle deep linking parameters - Added deep linking support configuration in main.dart - Improved router with URL parameter extraction helpers
This commit is contained in:
@@ -186,13 +186,8 @@ class _LoginPageState extends State<LoginPage> {
|
||||
}
|
||||
|
||||
void _handleForgotPassword() {
|
||||
// TODO: Navigate to forgot password screen
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Forgot password feature coming soon'),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
// Navigate to password reset page
|
||||
context.go('/reset-password');
|
||||
}
|
||||
|
||||
void _handleSignUp() {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../providers/auth_provider.dart';
|
||||
import '../../../../core/errors/auth_exceptions.dart';
|
||||
import '../../../../core/router/app_router.dart';
|
||||
|
||||
/// Password reset confirmation page
|
||||
///
|
||||
@@ -32,22 +34,47 @@ class _ResetPasswordConfirmPageState extends ConsumerState<ResetPasswordConfirmP
|
||||
});
|
||||
|
||||
try {
|
||||
// Check if we have a valid reset session by attempting to get current user
|
||||
final authProvider = ref.read(authProvider.notifier);
|
||||
await authProvider.getCurrentUser();
|
||||
// Extract token and email from URL parameters (deep linking)
|
||||
final resetData = AppRouter.handlePasswordResetDeepLink(context);
|
||||
final token = resetData['token'];
|
||||
final email = resetData['email'];
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_tokenValid = true;
|
||||
});
|
||||
if (token != null && email != null) {
|
||||
// Validate token with auth provider
|
||||
final authProvider = ref.read(authProvider.notifier);
|
||||
await authProvider.validateResetToken(token, email);
|
||||
|
||||
// Navigate to update password page after short delay
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pushReplacementNamed('/update-password');
|
||||
}
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_tokenValid = true;
|
||||
});
|
||||
|
||||
// Navigate to update password page after short delay
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
if (mounted) {
|
||||
context.go('/update-password?token=$token&email=$email');
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// No token found, try to get current user (for email flow)
|
||||
final authProvider = ref.read(authProvider.notifier);
|
||||
await authProvider.getCurrentUser();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_tokenValid = true;
|
||||
});
|
||||
|
||||
// Navigate to update password page after short delay
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
if (mounted) {
|
||||
context.go('/update-password');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
|
||||
@@ -137,6 +137,22 @@ class _SignupPageState extends State<SignupPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Forgot password link
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: TextButton(
|
||||
onPressed: _handleForgotPassword,
|
||||
child: Text(
|
||||
'Forgot Password?',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -335,4 +351,9 @@ class _SignupPageState extends State<SignupPage> {
|
||||
// Navigate to sign in page
|
||||
context.go('/login');
|
||||
}
|
||||
|
||||
void _handleForgotPassword() {
|
||||
// Navigate to password reset page
|
||||
context.go('/reset-password');
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../widgets/auth_button.dart';
|
||||
import '../providers/auth_provider.dart';
|
||||
import '../../../../core/errors/auth_exceptions.dart';
|
||||
import '../../../../core/utils/password_validator.dart';
|
||||
import '../../../../core/router/app_router.dart';
|
||||
|
||||
/// Password update page for handling password reset from email links
|
||||
///
|
||||
@@ -28,6 +30,15 @@ class _UpdatePasswordPageState extends ConsumerState<UpdatePasswordPage> {
|
||||
String? _errorMessage;
|
||||
bool _passwordUpdated = false;
|
||||
|
||||
String? _resetToken;
|
||||
String? _resetEmail;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_extractResetParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_newPasswordController.dispose();
|
||||
@@ -35,6 +46,17 @@ class _UpdatePasswordPageState extends ConsumerState<UpdatePasswordPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Extract reset token and email from URL parameters for deep linking
|
||||
void _extractResetParameters() {
|
||||
final resetData = AppRouter.handlePasswordResetDeepLink(context);
|
||||
_resetToken = resetData['token'];
|
||||
_resetEmail = resetData['email'];
|
||||
|
||||
if (_resetToken != null && _resetEmail != null) {
|
||||
print('Reset parameters extracted for email: $_resetEmail');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handlePasswordUpdate() async {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
|
||||
@@ -45,9 +67,20 @@ class _UpdatePasswordPageState extends ConsumerState<UpdatePasswordPage> {
|
||||
|
||||
try {
|
||||
final authProvider = ref.read(authProvider.notifier);
|
||||
await authProvider.updatePasswordFromReset(
|
||||
_newPasswordController.text.trim(),
|
||||
);
|
||||
|
||||
// Use reset token and email if available (from deep linking)
|
||||
if (_resetToken != null && _resetEmail != null) {
|
||||
await authProvider.updatePasswordWithToken(
|
||||
_resetToken!,
|
||||
_resetEmail!,
|
||||
_newPasswordController.text.trim(),
|
||||
);
|
||||
} else {
|
||||
// Fallback to regular password update
|
||||
await authProvider.updatePasswordFromReset(
|
||||
_newPasswordController.text.trim(),
|
||||
);
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
||||
Reference in New Issue
Block a user