Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function getRequestUserName() {
- return $_POST[self::$name];
- }
- public function getRequestPassword() {
- return $_POST[self::$password];
- }
- public function getKeepLoggedIn() {
- if (isset($_POST[self::$keep])) {
- return true;
- }
- return false;
- }
- public function userFilledInUsername() {
- if (isset($_POST[self::$name]) && !empty($_POST[self::$name])) {
- return true;
- }
- else {
- return false;
- }
- }
- public function userFilledInPassword() {
- if (isset($_POST[self::$password]) && !empty($_POST[self::$password])) {
- return true;
- }
- else {
- return false;
- }
- }
- public function userWantsToLogIn() {
- if (isset($_POST[self::$login])) {
- return true;
- }
- else {
- return false;
- }
- }
- public function userPressedLogout() {
- if (isset($_POST[self::$logout])) {
- return true;
- }
- else {
- return false;
- }
- }
- private function getResponseMessage() {
- if ($this->userWantsToLogIn()) {
- $username = $this->getRequestUserName();
- $password = $this->getRequestPassword();
- if ($this->userFilledInPassword() === false && $this->userFilledInUsername()) {
- return 'Password is missing';
- }
- if ($this->userFilledInUsername() === false) {
- return 'Username is missing';
- }
- if ($this->model->usernameExists($username) === false || $this->model->checkUsernameAndPassword($username, $password) === false) {
- return 'Wrong name or password';
- }
- if ($this->model->usernameExists($username) && $this->model->checkUsernameAndPassword($username, $password)) {
- return 'Welcome';
- }
- }
- if ($this->session->isCookieSet()) {
- return 'Welcome back with cookie';
- }
- if ($this->userPressedLogout()) {
- return 'Bye bye!';
- }
- return '';
- }
- private function setCookie() {
- if ($this->getKeepLoggedIn()) {
- $this->session->setKeepLoggedIn();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement