merge
This commit is contained in:
commit
1bde1c624a
@ -1,6 +1,6 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="main.dart" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="filePath" value="$PROJECT_DIR$/frontend/lib/main.dart" />
|
||||
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@ -306,7 +306,6 @@ import '../presentation/Screens/demo_home.dart';
|
||||
import '../presentation/Screens/profilepage.dart';
|
||||
import '../presentation/routes/auth_routes/login_route.dart';
|
||||
import '../presentation/routes/bottom_bar_routes/tab_routes/home_route.dart';
|
||||
import '../presentation/routes/drawer_routes/Drawer Items/edit_profile.dart';
|
||||
import '../presentation/routes/drawer_routes/Drawer Items/feedback.dart';
|
||||
import '../presentation/routes/drawer_routes/Drawer Items/manage_users.dart';
|
||||
|
||||
@ -314,8 +313,13 @@ final GoRouter router = GoRouter(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
//builder: (context, state) => LoginRoute(),
|
||||
builder: (context, state) => LoginRoute(),
|
||||
//builder: (context, state) => MyHomePage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/login',
|
||||
builder: (context, state) => LoginRoute(),
|
||||
|
||||
),
|
||||
GoRoute(
|
||||
path: '/myhomepage',
|
||||
@ -340,11 +344,10 @@ final GoRouter router = GoRouter(
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/changepassword/:userId',
|
||||
builder: (context, state) {
|
||||
final userId = state.pathParameters['userId']!;
|
||||
return Changepassword(userId: userId);
|
||||
},
|
||||
path: '/changepassword',
|
||||
builder: (context, state) => Changepassword(
|
||||
userId: '',
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/createNewPw/:userId/:email',
|
||||
@ -368,11 +371,10 @@ final GoRouter router = GoRouter(
|
||||
builder: (context, state) => FeedbackForm(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/profile/:userId',
|
||||
builder: (context, state) {
|
||||
final userId = state.pathParameters['userId']!;
|
||||
return ProfileScreen(userId: userId);
|
||||
},
|
||||
path: '/profile',
|
||||
builder: (context, state) => ProfileScreen(
|
||||
userId: '',
|
||||
),
|
||||
),
|
||||
// GoRoute(
|
||||
// path: '/manageuser',
|
||||
@ -382,13 +384,10 @@ final GoRouter router = GoRouter(
|
||||
// return ManageUserRouter(title: title);
|
||||
// },
|
||||
// ),
|
||||
GoRoute(
|
||||
path: '/editProfile',
|
||||
builder: (context, state) => EditProfile(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/manageuser',
|
||||
builder: (context, state) => ManageUserRouter(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ import 'package:pocketbase/pocketbase.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/presentation/Screens/profilepage.dart';
|
||||
|
||||
import '../../../infrastructure/services/pocketbase_service.dart';
|
||||
import '../../routes/auth_routes/login_route.dart';
|
||||
|
||||
class RegisterScreen extends StatefulWidget {
|
||||
@ -136,77 +135,27 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
return null;
|
||||
}
|
||||
|
||||
// String? _validatePassword(String? value) {
|
||||
// // Define the regular expression for allowed characters
|
||||
// final regex = RegExp(
|
||||
// r'^[A-Za-z0-9~!@#$%^&*()_+=[\]{}|;:,.<>?/-àèìòùáéíóúÀÈÌÒÙÁÉÍÓÚ]*$');
|
||||
//
|
||||
// if (value == null || value.isEmpty) {
|
||||
// return 'Required';
|
||||
// } else if (value.length < 8) {
|
||||
// return 'Password must be at least 8characters';
|
||||
// }
|
||||
//
|
||||
// // Check the length constraint
|
||||
// if (value.length < 8 || value.length > 40) {
|
||||
// return 'Password must be between 8 and 64 characters';
|
||||
// }
|
||||
//
|
||||
// // Check the regular expression
|
||||
// if (!regex.hasMatch(value)) {
|
||||
// return 'Password contains invalid characters';
|
||||
// }
|
||||
//
|
||||
// _password = value; // Store the password for confirm password validation
|
||||
// return null;
|
||||
// }
|
||||
|
||||
String? _validatePassword(String? value) {
|
||||
// Define the regular expression for allowed characters
|
||||
final regex = RegExp(
|
||||
r'^[A-Za-z0-9~!@#$%^&*()_+=[\]{}|;:,.<>?/-àèìòùáéíóúÀÈÌÒÙÁÉÍÓÚ]*$');
|
||||
|
||||
// Define regular expressions for password complexity requirements
|
||||
final hasUppercase = RegExp(r'[A-Z]');
|
||||
final hasLowercase = RegExp(r'[a-z]');
|
||||
final hasDigit = RegExp(r'\d');
|
||||
final hasSpecialCharacter = RegExp(r'[~!@#$%^&*()_+=[\]{}|;:,.<>?/-]');
|
||||
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Required';
|
||||
} else if (value.length < 8) {
|
||||
return 'Password must be at least 8characters';
|
||||
}
|
||||
|
||||
// Check the length constraint
|
||||
if (value.length < 8 || value.length > 64) {
|
||||
if (value.length < 8 || value.length > 40) {
|
||||
return 'Password must be between 8 and 64 characters';
|
||||
}
|
||||
|
||||
// Check the regular expression for allowed characters
|
||||
// Check the regular expression
|
||||
if (!regex.hasMatch(value)) {
|
||||
return 'Password contains invalid characters';
|
||||
}
|
||||
|
||||
// Track missing constraints
|
||||
List<String> missingConstraints = [];
|
||||
|
||||
if (!hasUppercase.hasMatch(value)) {
|
||||
missingConstraints.add('uppercase letter');
|
||||
}
|
||||
if (!hasLowercase.hasMatch(value)) {
|
||||
missingConstraints.add('lowercase letter');
|
||||
}
|
||||
if (!hasDigit.hasMatch(value)) {
|
||||
missingConstraints.add('numeric digit');
|
||||
}
|
||||
if (!hasSpecialCharacter.hasMatch(value)) {
|
||||
missingConstraints.add('special character');
|
||||
}
|
||||
|
||||
// If there are missing constraints, return a consolidated message
|
||||
if (missingConstraints.isNotEmpty) {
|
||||
return 'At least one ${missingConstraints.join(', ')}';
|
||||
}
|
||||
|
||||
_password = value; // Store the password for confirm password validation
|
||||
return null;
|
||||
}
|
||||
@ -245,7 +194,6 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
'password': _passwordController.text,
|
||||
'passwordConfirm': _passwordController.text,
|
||||
'status': 'Pending',
|
||||
'role': 'user',
|
||||
}, headers: {
|
||||
'Authorization': adminToken
|
||||
});
|
||||
@ -259,6 +207,13 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
registrationSuccess = true;
|
||||
registrationFailed = false; // Show success message on success
|
||||
});
|
||||
|
||||
// Navigate to ProfileScreen after successful registration
|
||||
// Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => ProfileScreen(userId: response.id)),
|
||||
// );
|
||||
} else {
|
||||
throw Exception('User registration failed: missing user ID');
|
||||
}
|
||||
@ -343,7 +298,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
buildIconContainer(Icons.report, Color(0xFF7DAFBC)),
|
||||
SizedBox(height: 20),
|
||||
Text(
|
||||
"Your registration is pending for verification",
|
||||
"Your registration is pending for Admin Approval.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
@ -352,7 +307,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
"Kindly verify your mail to proceed further.",
|
||||
"Access will be granted once your account is approved.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
@ -361,8 +316,14 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
context.go('/');
|
||||
onPressed: () => {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => LoginRoute()
|
||||
|
||||
//ProfileScreen(userId: userID)
|
||||
),
|
||||
),
|
||||
},
|
||||
child: Text(
|
||||
'Go to Login',
|
||||
@ -517,8 +478,8 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_obscurePassword
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
color: Colors.blue,
|
||||
),
|
||||
onPressed: () {
|
||||
@ -549,8 +510,8 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_obscureConfirmPassword
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
color: Colors.blue,
|
||||
),
|
||||
onPressed: () {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user