From 58eeaba11f1abcccb947fa907c9eb23dc12a76f6 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 9 Mar 2016 15:04:31 +0100 Subject: * user management --- app/php/pages/Admin.page | 1 + app/php/pages/Admin.php | 7 +++++++ app/php/pages/Login.page | 17 +++++++++++++++++ app/php/pages/Login.php | 20 ++++++++++++++++++++ app/php/pages/Profile.page | 1 + app/php/pages/Profile.php | 7 +++++++ app/php/pages/Signup.page | 37 +++++++++++++++++++++++++++++++++++++ app/php/pages/Signup.php | 27 +++++++++++++++++++++++++++ app/php/pages/config.xml | 7 +++++++ 9 files changed, 124 insertions(+) create mode 100644 app/php/pages/Admin.page create mode 100644 app/php/pages/Admin.php create mode 100644 app/php/pages/Login.page create mode 100644 app/php/pages/Login.php create mode 100644 app/php/pages/Profile.page create mode 100644 app/php/pages/Profile.php create mode 100644 app/php/pages/Signup.page create mode 100644 app/php/pages/Signup.php create mode 100644 app/php/pages/config.xml (limited to 'app/php/pages') diff --git a/app/php/pages/Admin.page b/app/php/pages/Admin.page new file mode 100644 index 0000000..431a6fb --- /dev/null +++ b/app/php/pages/Admin.page @@ -0,0 +1 @@ +Page diff --git a/app/php/pages/Admin.php b/app/php/pages/Admin.php new file mode 100644 index 0000000..3e8ee1a --- /dev/null +++ b/app/php/pages/Admin.php @@ -0,0 +1,7 @@ + diff --git a/app/php/pages/Login.page b/app/php/pages/Login.page new file mode 100644 index 0000000..d0825a0 --- /dev/null +++ b/app/php/pages/Login.page @@ -0,0 +1,17 @@ + + Username: + +
+ Password: + + +
+ +
diff --git a/app/php/pages/Login.php b/app/php/pages/Login.php new file mode 100644 index 0000000..d7be42b --- /dev/null +++ b/app/php/pages/Login.php @@ -0,0 +1,20 @@ +Page->IsValid) { + $this->Response->redirect( + $this->Application->getModule('auth')->ReturnUrl + ?: NULL + ); + } + } + + public function validatePassword($sender, $param) { + $param->IsValid = $this->Application->getModule('auth')->login($this->Login->Text, $this->Password->Text); + } + +} + +?> diff --git a/app/php/pages/Profile.page b/app/php/pages/Profile.page new file mode 100644 index 0000000..99455ed --- /dev/null +++ b/app/php/pages/Profile.page @@ -0,0 +1 @@ +Profile diff --git a/app/php/pages/Profile.php b/app/php/pages/Profile.php new file mode 100644 index 0000000..fb2c89f --- /dev/null +++ b/app/php/pages/Profile.php @@ -0,0 +1,7 @@ + diff --git a/app/php/pages/Signup.page b/app/php/pages/Signup.page new file mode 100644 index 0000000..0e35da2 --- /dev/null +++ b/app/php/pages/Signup.page @@ -0,0 +1,37 @@ + + Username: + + + +
+ Password: + +
+ Repeat password: + +
+ Admin: +
+ + +
diff --git a/app/php/pages/Signup.php b/app/php/pages/Signup.php new file mode 100644 index 0000000..c999e65 --- /dev/null +++ b/app/php/pages/Signup.php @@ -0,0 +1,27 @@ +IsValid = !User::finder()->countByLogin($this->Login->SafeText); + } + + public function registerUser($sender, $param) { + if ($this->Page->IsValid) { + $newUser = new User(); + $newUser->Login = $this->Login->SafeText; + $newUser->Password = password_hash($this->Password->Text, PASSWORD_DEFAULT); + $newUser->IsAdmin = $this->Admin->Checked; + $newUser->save(); + $this->Response->redirect($this->Request->constructUrl( + $this->Service->ID, + NULL + )); + } + } + +} + +?> diff --git a/app/php/pages/config.xml b/app/php/pages/config.xml new file mode 100644 index 0000000..d387667 --- /dev/null +++ b/app/php/pages/config.xml @@ -0,0 +1,7 @@ + + + + + + + -- cgit v1.2.3