diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml deleted file mode 100644 index 86b1c24..0000000 --- a/.idea/libraries/Dart_Packages.xml +++ /dev/null @@ -1,588 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 6ae284f..008f0f6 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Sources/dafl_project_flutter/lib/controller/controller.dart b/Sources/dafl_project_flutter/lib/controller/controller.dart index 053e331..498f729 100644 --- a/Sources/dafl_project_flutter/lib/controller/controller.dart +++ b/Sources/dafl_project_flutter/lib/controller/controller.dart @@ -1,10 +1,12 @@ import '../persistence/database_loader.dart'; import '../persistence/database_saver.dart'; +import '../persistence/database_searcher.dart'; import '../persistence/loader.dart'; import '../persistence/saver.dart'; import '../persistence/loader.dart'; import '../model/user.dart'; +import '../persistence/searcher.dart'; class Controller{ @@ -12,6 +14,7 @@ class Controller{ static Saver? saver = DatabaseSaver(); static Loader? loader = DatabaseLoader(); + static Searcher _searcher = DatabaseSearcher(); User currentUser = User(null, null); @@ -48,4 +51,8 @@ class Controller{ this.currentUser?.passwDafl = newPass; } } + + Future searchByUsername(String username) async{ + return _searcher.searchByUsername(username); + } } diff --git a/Sources/dafl_project_flutter/lib/persistence/database_search.dart b/Sources/dafl_project_flutter/lib/persistence/database_search.dart deleted file mode 100644 index e69de29..0000000 diff --git a/Sources/dafl_project_flutter/lib/persistence/database_searcher.dart b/Sources/dafl_project_flutter/lib/persistence/database_searcher.dart new file mode 100644 index 0000000..6148e8a --- /dev/null +++ b/Sources/dafl_project_flutter/lib/persistence/database_searcher.dart @@ -0,0 +1,25 @@ +import 'package:dafl_project_flutter/persistence/database_connexion.dart'; + +import 'searcher.dart'; + +class DatabaseSearcher extends Searcher{ + DatabaseConnexion dbConnexion = DatabaseConnexion(); + + Future searchUser(String? username, String? password) async { return true; } + + + @override + Future searchByUsername(String? username) async{ + final connection = await dbConnexion.initConnexion(); + + connection.query('select * from utilisateur where username = $username').toList().then((rows) { + if(rows.isEmpty){ + connection.close(); + return false; + } + }); + + connection.close(); + return true; + } +} \ No newline at end of file diff --git a/Sources/dafl_project_flutter/lib/persistence/search.dart b/Sources/dafl_project_flutter/lib/persistence/search.dart deleted file mode 100644 index 76bb714..0000000 --- a/Sources/dafl_project_flutter/lib/persistence/search.dart +++ /dev/null @@ -1,6 +0,0 @@ -import '../model/user.dart'; - -abstract class Search{ - bool searchUser(String? username, String? password); - bool searchUsername(String? username); -} \ No newline at end of file diff --git a/Sources/dafl_project_flutter/lib/persistence/searcher.dart b/Sources/dafl_project_flutter/lib/persistence/searcher.dart index 76bb714..276a197 100644 --- a/Sources/dafl_project_flutter/lib/persistence/searcher.dart +++ b/Sources/dafl_project_flutter/lib/persistence/searcher.dart @@ -1,6 +1,6 @@ import '../model/user.dart'; -abstract class Search{ - bool searchUser(String? username, String? password); - bool searchUsername(String? username); +abstract class Searcher{ + Future searchUser(String? username, String? password); + Future searchByUsername(String? username); } \ No newline at end of file diff --git a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart index e09ee2a..af4f2d4 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart @@ -298,10 +298,14 @@ class _SignUpPageState extends State { ); } - void checkInformations(String username,String password, String confirmPassword){ + Future checkInformations(String username,String password, String confirmPassword) async { if(username ==""){ Notify(2, context); } + else if(! await MyApp().controller.searchByUsername(username)){ + Notify(0, context); + } + /* else if(password =="" || confirmPassword == ""){ Notify(4, context); } @@ -314,6 +318,7 @@ class _SignUpPageState extends State { else if(password != confirmPassword){ Notify(1, context); } + */ else{ MyApp().controller.save(User(userNameTextField.text, passwordConfirmTextField.text)); Navigator.of(context).push(