summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-27 03:19:43 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-27 03:19:43 +0300
commitfa7303bc99ed56e6770928d59e16ee3306e26750 (patch)
tree68e475e778764d1d50d16375567995432b3fd15f
parente32735e01bab8f73ce0fb0413254cfd8e18249e2 (diff)
downloadclassroom-fa7303bc99ed56e6770928d59e16ee3306e26750.tar.gz
classroom-fa7303bc99ed56e6770928d59e16ee3306e26750.tar.bz2
classroom-fa7303bc99ed56e6770928d59e16ee3306e26750.zip
several tests on user_manager extension
-rw-r--r--core/classes/Request.php2
-rw-r--r--core/classes/authentication/Core/PasswordTrait.php6
-rw-r--r--core/classes/authentication/Core/UserManager.php10
-rw-r--r--core/classes/authentication/Core/UserManagerInterface.php8
-rw-r--r--core/classes/authentication/Token/UserToken.php6
-rw-r--r--core/classes/authentication/Token/UserTokenInterface.php6
-rw-r--r--core/classes/authentication/User.php3
-rw-r--r--core/classes/authentication/UserInterface.php2
-rw-r--r--core/config/init.php1
-rw-r--r--html/app/controllers/Classroom_user.php (renamed from html/app/extends/ClassUserMagager.php)23
-rw-r--r--html/app/models/admin/User_model.php5
-rw-r--r--html/app/routes/frontend.php9
-rw-r--r--html/app/views/login.php4
-rw-r--r--tests/userman.php25
14 files changed, 76 insertions, 34 deletions
diff --git a/core/classes/Request.php b/core/classes/Request.php
index 6b82dc5..cedb8a1 100644
--- a/core/classes/Request.php
+++ b/core/classes/Request.php
@@ -87,7 +87,7 @@ class Request
// TODO:
// ...
// if SCRF-token is not valideted, serve 403
- return $array;
+ return true;
}
diff --git a/core/classes/authentication/Core/PasswordTrait.php b/core/classes/authentication/Core/PasswordTrait.php
index 2d3cbd2..40a7381 100644
--- a/core/classes/authentication/Core/PasswordTrait.php
+++ b/core/classes/authentication/Core/PasswordTrait.php
@@ -4,9 +4,9 @@
* @package DevCoder\Authentication\Core
*
*/
-// namespace DevCoder\Authentication\Core;
-
-// use DevCoder\Authentication\UserInterface;
+# namespace DevCoder\Authentication\Core;
+#
+# use DevCoder\Authentication\UserInterface;
trait PasswordTrait
{
diff --git a/core/classes/authentication/Core/UserManager.php b/core/classes/authentication/Core/UserManager.php
index 776cee9..a3c1cd5 100644
--- a/core/classes/authentication/Core/UserManager.php
+++ b/core/classes/authentication/Core/UserManager.php
@@ -4,11 +4,11 @@
* @package DevCoder\Authentication\Core
*
*/
-// namespace DevCoder\Authentication\Core;
-
-// use DevCoder\Authentication\Token\UserToken;
-// use DevCoder\Authentication\Token\UserTokenInterface;
-// use DevCoder\Authentication\UserInterface;
+# namespace DevCoder\Authentication\Core;
+#
+# use DevCoder\Authentication\Token\UserToken;
+# use DevCoder\Authentication\Token\UserTokenInterface;
+# use DevCoder\Authentication\UserInterface;
class UserManager implements UserManagerInterface
{
diff --git a/core/classes/authentication/Core/UserManagerInterface.php b/core/classes/authentication/Core/UserManagerInterface.php
index 4702992..05110fb 100644
--- a/core/classes/authentication/Core/UserManagerInterface.php
+++ b/core/classes/authentication/Core/UserManagerInterface.php
@@ -4,10 +4,10 @@
* @package DevCoder\Authentication\Core
*
*/
-// namespace DevCoder\Authentication\Core;
-
-// use DevCoder\Authentication\Token\UserTokenInterface;
-// use DevCoder\Authentication\UserInterface;
+# namespace DevCoder\Authentication\Core;
+#
+# use DevCoder\Authentication\Token\UserTokenInterface;
+# use DevCoder\Authentication\UserInterface;
interface UserManagerInterface
{
diff --git a/core/classes/authentication/Token/UserToken.php b/core/classes/authentication/Token/UserToken.php
index 520d4ad..b9bb024 100644
--- a/core/classes/authentication/Token/UserToken.php
+++ b/core/classes/authentication/Token/UserToken.php
@@ -4,9 +4,9 @@
* @package DevCoder\Authentication
*
*/
-// namespace DevCoder\Authentication\Token;
-
-// use DevCoder\Authentication\UserInterface;
+# namespace DevCoder\Authentication\Token;
+#
+# use DevCoder\Authentication\UserInterface;
class UserToken implements UserTokenInterface
{
diff --git a/core/classes/authentication/Token/UserTokenInterface.php b/core/classes/authentication/Token/UserTokenInterface.php
index f095a17..8e8b642 100644
--- a/core/classes/authentication/Token/UserTokenInterface.php
+++ b/core/classes/authentication/Token/UserTokenInterface.php
@@ -4,9 +4,9 @@
* @package DevCoder\Authentication\Token
*
*/
-// namespace DevCoder\Authentication\Token;
-
-// use DevCoder\Authentication\UserInterface;
+# namespace DevCoder\Authentication\Token;
+#
+# use DevCoder\Authentication\UserInterface;
interface UserTokenInterface
{
diff --git a/core/classes/authentication/User.php b/core/classes/authentication/User.php
index cc9d5e3..06f0ddb 100644
--- a/core/classes/authentication/User.php
+++ b/core/classes/authentication/User.php
@@ -6,7 +6,7 @@
* @package DevCoder\Authentication
*
*/
-// namespace DevCoder\Authentication;
+# namespace DevCoder\Authentication;
class User implements UserInterface
{
@@ -27,6 +27,7 @@ class User implements UserInterface
private $enabled = true;
+
/** GETs
* -------------------------------------------------------------------------
*/
diff --git a/core/classes/authentication/UserInterface.php b/core/classes/authentication/UserInterface.php
index f81a9ee..b035215 100644
--- a/core/classes/authentication/UserInterface.php
+++ b/core/classes/authentication/UserInterface.php
@@ -5,7 +5,7 @@
* @package DevCoder\Authentication
*
*/
-// namespace DevCoder\Authentication;
+# namespace DevCoder\Authentication;
interface UserInterface
{
diff --git a/core/config/init.php b/core/config/init.php
index 2db2503..0dbaaf0 100644
--- a/core/config/init.php
+++ b/core/config/init.php
@@ -16,7 +16,6 @@
* anything else can be injected on-demand
*/
-
// setup error-handliing
// -----------------------------------------------------------------------------
require_once '../core/helpers/error_handling.php';
diff --git a/html/app/extends/ClassUserMagager.php b/html/app/controllers/Classroom_user.php
index c365670..616ebf6 100644
--- a/html/app/extends/ClassUserMagager.php
+++ b/html/app/controllers/Classroom_user.php
@@ -1,9 +1,11 @@
<?php
+namespace app\controllers;
+
+use UserManager;
+use Registry;
+# use app\models\admin\User_model;
-namespace app\extends;
-use app\models\admin\User_model;
-use \Registry;
/** ClassUserManager
*
@@ -13,18 +15,24 @@ use \Registry;
* according to this app's special rules
*
*/
-class ClassUserMagager extends UserManager
+class Classroom_user extends UserManager
{
- public function create_user()
- {
+ private $user_identifier = 'email'; // identifing user field (username, email, etc )
+ protected $user;
+
+ public function __construct()
+ {
+ // $this->user = new UserManager();
+
}
public function register_user()
{
-
+ $req = Registry::get('REQUEST');
+ print_r($req->POST); die();
}
@@ -58,5 +66,4 @@ class ClassUserMagager extends UserManager
}
-
} \ No newline at end of file
diff --git a/html/app/models/admin/User_model.php b/html/app/models/admin/User_model.php
index 80ce113..583d4d9 100644
--- a/html/app/models/admin/User_model.php
+++ b/html/app/models/admin/User_model.php
@@ -13,9 +13,12 @@ class User_model
* @param $indexKey (string) : key for user identification
* @param $value (string)
*
- * NOTE: $indexKey MUST BE a unique key
+ * NOTE:
+ * $indexKey MUST BE a unique key identilieng the user
+ * ex. username, email, etc ...
*
* @return $user : [array] or false
+ *
*/
public static function checkUser($indexKey, $value)
{
diff --git a/html/app/routes/frontend.php b/html/app/routes/frontend.php
index 191ce4e..7bd1ee8 100644
--- a/html/app/routes/frontend.php
+++ b/html/app/routes/frontend.php
@@ -2,7 +2,7 @@
use app\controllers\Resolve;
use app\controllers\Product;
-
+use app\controllers\Classroom_user;
// Home/Welcome
// ---
@@ -21,6 +21,13 @@ Route::notFound( function() {
Route::add('/login', function() { Render::view('login'); });
+Route::add('/login-check', function() {
+ $user = new Classroom_user();
+ $user->register_user();
+ },
+ 'post'
+);
+
// Resolve urls
// --- -- -- - - -
diff --git a/html/app/views/login.php b/html/app/views/login.php
index 769b660..cc4556c 100644
--- a/html/app/views/login.php
+++ b/html/app/views/login.php
@@ -38,11 +38,11 @@
<form method="post" action="/login-check">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Email</label>
- <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
+ <input type="email" class="form-control" id="exampleInputEmail1" name="email" aria-describedby="emailHelp">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Password</label>
- <input type="password" class="form-control" id="exampleInputPassword1">
+ <input type="password" class="form-control" id="exampleInputPassword1" name="password">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
diff --git a/tests/userman.php b/tests/userman.php
new file mode 100644
index 0000000..c08028c
--- /dev/null
+++ b/tests/userman.php
@@ -0,0 +1,25 @@
+<?php
+namespace tests;
+
+//use UserManager;
+use app\controllers\Classroom_user as CU;
+
+
+//$a = new UserManager();
+//
+$u = new CU();
+
+/*
+class ClassroomUserManager extends UserManager
+{
+
+ private $user_identifier = 'email'; // identifing user field (username, email, etc )
+
+ public function __construct()
+ {
+ parent::__construct();
+ }
+}
+
+$u = new ClassroomUserManager();
+*/ \ No newline at end of file