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