diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/classes/Database.php | 2 | ||||
| -rw-r--r-- | core/classes/Request.php | 53 | ||||
| -rw-r--r-- | core/classes/User.php | 111 | ||||
| -rw-r--r-- | core/classes/authentication/User.php | 22 |
4 files changed, 77 insertions, 111 deletions
diff --git a/core/classes/Database.php b/core/classes/Database.php index 35ff65f..629753c 100644 --- a/core/classes/Database.php +++ b/core/classes/Database.php @@ -82,9 +82,11 @@ class Database { * --- * set and execute a query safely; * save results as associative array; DO NOT RETURN RESULTS + * * @param $sql (string): SQL query * @param $args (array): array of values to bind into SQL * @param $pypass (boolean): flag to bypass security check + * * @return $this (database handler) */ public function query($sql, $args=[]) diff --git a/core/classes/Request.php b/core/classes/Request.php index 20b82c7..6b82dc5 100644 --- a/core/classes/Request.php +++ b/core/classes/Request.php @@ -89,6 +89,59 @@ class Request // if SCRF-token is not valideted, serve 403 return $array; } + + + + + public function isAjax(): bool + { + // check headers 'XMLHttpRequest' == $this->headers->get('X-Requested-With'); + } + + + public function isSecure(): bool + { + // chech if HTTPS + } + + + public function hasSession(): bool + { + // chech if Session exist + } + + + /** + * Get the user making the request. + * + * @param string|null $guard + * @return mixed + */ + public function user($guard = null) + { + // return call_user_func($this->getUserResolver(), $guard); + } + + public function getUserResolver() + { + // return $this->userResolver ?: function () { + // + // }; + } + + /** + * Set the user resolver callback. + * + * @param \Closure $callback + * @return $this + */ + public function setUserResolver(Closure $callback) + { + // $this->userResolver = $callback; + // return $this; + } + + } diff --git a/core/classes/User.php b/core/classes/User.php deleted file mode 100644 index 65b5018..0000000 --- a/core/classes/User.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -class User_depricated -{ - - /** PROPERTIES - * ------------------------------------------------------------------------- - */ - - private $isLogged = false; - - private $who = Array( - 'title' => '', - 'name' => '', - 'middle'=> '', - 'surname' =>'', - 'email' => '' - ); - - private $addresses = Array(); - - - - /** METHODS - * ------------------------------------------------------------------------- - */ - - - public function create() - { - - } - - - public function setDefaultAddress($id) - { - - } - - - public function addAddress() - { - // update session data - // update user record - } - - - public function changePassword() - { - - } - - - public function confirmEmail() - { - - } - - - public function sendEmail() - { - - } - - /** sendOTP() - * sent One-Time-Password - * - */ - public function sendOTP($ttl) - { - $to = $this->who; - $otp = rand(10000,99999); - $expire = time() + $ttl; - - $mail = new PHPMailer(true); - try { - //Server settings - // ... - - //Recipients - $mail->setFrom('from@example.com', 'Mailer'); - $mail->addAddress($to['email'], $to['surname'] .' '. $to['name']); //Add a recipient - $mail->addReplyTo('info@example.com', 'Information'); - - //Attachments - $mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments - $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name - - //Content - $mail->isHTML(true); //Set email format to HTML - $mail->Subject = 'Your OTP'; - $mail->Body = 'This is the HTML message body <b>in bold!</b>'; - $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; - - $mail->send(); - echo 'Message has been sent'; - } catch (Exception $e) { - echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; - } - - } - - /** updateSession() - * regenerates session - */ - public function updateSession() - { - - } - -} diff --git a/core/classes/authentication/User.php b/core/classes/authentication/User.php index 4aef375..cc9d5e3 100644 --- a/core/classes/authentication/User.php +++ b/core/classes/authentication/User.php @@ -20,6 +20,9 @@ class User implements UserInterface // @var array private $roles = []; + // @var array + private $privileges = []; + // @var bool private $enabled = true; @@ -52,6 +55,14 @@ class User implements UserInterface return $this->roles; } + /** getPrivileges + * @return array + */ + public function getPrivileges(): array + { + return $this->privileges; + } + /** isEnabled * @return bool */ @@ -98,6 +109,17 @@ class User implements UserInterface return $this; } + /** setPrivileges() + * + * @param array $roles + * @return User + */ + public function setPrivileges(array $privileges): self + { + $this->privileges = $privileges; + return $this; + } + /** setEnabled * * @param bool $enabled |
