From d3ccc39e57cf7b6a0e114408b14ccea30310d905 Mon Sep 17 00:00:00 2001 From: Olusesan Ameye Date: Wed, 5 Feb 2020 06:05:47 -0500 Subject: [PATCH] fix --- www/application/config/constants.php | 8 ++ www/application/controllers/Auth.php | 82 ++++++++++- www/application/controllers/Vemail.php | 60 ++++++++ www/application/core/COR_Controller.php | 6 +- www/application/views/auth/view_pending.php | 60 ++++++++ www/application/views/auth/view_register.php | 130 +++++++++--------- .../views/auth/view_reset_password.php | 2 +- .../views/member/view_securehead.php | 2 +- 8 files changed, 277 insertions(+), 73 deletions(-) create mode 100644 www/application/controllers/Vemail.php create mode 100644 www/application/views/auth/view_pending.php diff --git a/www/application/config/constants.php b/www/application/config/constants.php index 18d3b4b..bd6037a 100644 --- a/www/application/config/constants.php +++ b/www/application/config/constants.php @@ -83,3 +83,11 @@ defined('EXIT_USER_INPUT') OR define('EXIT_USER_INPUT', 7); // invalid user defined('EXIT_DATABASE') OR define('EXIT_DATABASE', 8); // database error defined('EXIT__AUTO_MIN') OR define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code + + + +define('COREGRADE_ACCOUNT_TESTEMAIL',11001); +define('COREGRADE_ACCOUNT_PENDING',11010); +define('COREGRADE_VERIFY_PENDING_LINK',11015); +define('COREGRADE_ACCOUNT_CREATEACC',11020); +define('COREGRADE_ACCOUNT_LOGIN',11025); \ No newline at end of file diff --git a/www/application/controllers/Auth.php b/www/application/controllers/Auth.php index 1cdb958..2aa8ef0 100644 --- a/www/application/controllers/Auth.php +++ b/www/application/controllers/Auth.php @@ -7,13 +7,54 @@ class Auth extends Start_Controller { public function index() { $login_done = false; $data = array(); + $username = ''; + $password = ''; + $error_message = ''; + $valid_entry = false; + $valid_login = false; + $out = []; + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + + + $this->testLoginInput($username, $password, $error_message, $valid_entry); + + if (true == $valid_entry) { + if ($username != '' && $password != '') { + + $data["page_title"] = ""; + $data["username"] = $username; //"auxsupport"; + $data["password"] = $password; + $out = []; + $this->coregrade_webapi(COREGRADE_ACCOUNT_LOGIN, $data, $out); + //print_r( $data ); + //print_r( $out ); + if (count($out) > 0 && isset($out["session"])) { + //print_r($out); + //$this->getSessionData($out[0], $session_data); // just for testing + + $this->buildUserSession(PHP_API_OK, $out); + $valid_login = true; + $this->session->set_flashdata('in', $out); + // redirect("page/index"); + } else { + $error_message = "Invalid Username/Password"; + } + } + } + + + $this->renderMemberPages('view_dash', $data); $login_done = true; // exit(); } + echo 'hhhh jjjj'; + $this->coregrade_webapi(100, $data, $out); + + print_r($out); if (false == $login_done) { $this->renderAuthPages('view_login', $data); @@ -22,6 +63,41 @@ class Auth extends Start_Controller { public function newuser() { //$this->load->view('home/home'); + $data["firstname"] = $data["lastname"] = $data["password"] = $data["email"] = ""; + $valid_entry = true; + $valid_login = false; + + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + + $data['firstname'] = trim($this->input->post('firstname')); + $data['lastname'] = trim($this->input->post('lastname')); + $data['username'] = trim($this->input->post('username')); + $data['password'] = trim($this->input->post('pass1')); + $data['email'] = $data['username']; + + if (true == $valid_entry) { + if ($data['username'] != '' && $data['password'] != '') { + $out = []; + $this->coregrade_webapi(COREGRADE_ACCOUNT_PENDING, $data, $out); + + //print_r( $data ); + // print_r($out); + if (count($out) > 0 && isset($out["pending_id"]) && $out["pending_id"] > 0) { + //print_r($out); + //$this->getSessionData($out[0], $session_data); // just for testing + + $this->renderAuthPages('view_pending', $data); + $login_done = true; + // redirect("page/index"); + } else { + $error_message = "Invalid Username/Password"; + } + } + } + // exit(); + } + + $this->load->view('auth/view_head'); $this->load->view('auth/view_register'); $this->load->view('auth/view_foot'); @@ -35,8 +111,8 @@ class Auth extends Start_Controller { $this->load->view('auth/view_foot'); } - - - + public function logout() { + $this->index(); + } } diff --git a/www/application/controllers/Vemail.php b/www/application/controllers/Vemail.php new file mode 100644 index 0000000..bb58fae --- /dev/null +++ b/www/application/controllers/Vemail.php @@ -0,0 +1,60 @@ +load->view('home/home'); + $valid_entry = true; + $valid_login = false; + + if ($_SERVER['REQUEST_METHOD'] == 'GET') { + + $data['verify_link'] = trim($this->input->get('vlnk')); + + if (true == $valid_entry) { + if ($data['verify_link'] != '') { + $out = []; + $this->coregrade_webapi(COREGRADE_ACCOUNT_CREATEACC, $data, $out); + //print_r( $data ); + //print_r( $out ); + if (count($out) > 0 && isset($out["session"])) { + //print_r($out); + //$this->getSessionData($out[0], $session_data); // just for testing + + $this->buildUserSession(PHP_API_OK, $out); + $valid_login = true; + $this->session->set_flashdata('in', $out); + + $this->renderMemberPages('view_dash', $data); + $login_done = true; + + // redirect("page/index"); + } else { + $error_message = "Invalid Username/Password"; + } + } + } + + + + + // exit(); + } + + + $this->load->view('auth/view_head'); + $this->load->view('auth/view_register'); + $this->load->view('auth/view_foot'); + } + + public function resetpass() { + //$this->load->view('home/home'); + //echo "START RESET 1"; + $this->load->view('auth/view_head'); + $this->load->view('auth/view_reset_password'); + $this->load->view('auth/view_foot'); + } + +} diff --git a/www/application/core/COR_Controller.php b/www/application/core/COR_Controller.php index 49300ca..c7db4fb 100644 --- a/www/application/core/COR_Controller.php +++ b/www/application/core/COR_Controller.php @@ -52,6 +52,7 @@ class COR_Controller extends CI_Controller { $this->load->model('backend_model'); $in["action"] = $action; $in["pid"] = 100; + // print_r($in); $ret = $this->backend_model->coregrade_api($in, $out); //echo $ret; return $ret; @@ -67,7 +68,7 @@ class COR_Controller extends CI_Controller { $this->load->view('member/view_securefoot'); return 0; } - + protected function renderAuthPages($pagename, $data) { $this->load->view('auth/view_head'); @@ -76,6 +77,5 @@ class COR_Controller extends CI_Controller { return 0; } - - } + diff --git a/www/application/views/auth/view_pending.php b/www/application/views/auth/view_pending.php new file mode 100644 index 0000000..76f01b3 --- /dev/null +++ b/www/application/views/auth/view_pending.php @@ -0,0 +1,60 @@ + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+ branding logo +
+
+
+
+
+

Check your Email

+
+
+

Please check your email to continue.

+
+
+
+
+ Message Here ... +
+ +
+
+ +
+
+ Logn now +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/www/application/views/auth/view_register.php b/www/application/views/auth/view_register.php index f64ff43..45cb78f 100644 --- a/www/application/views/auth/view_register.php +++ b/www/application/views/auth/view_register.php @@ -1,78 +1,78 @@ - -
-
-
-
-
-
-
-
-
-
-
-
- branding logo -
-
-
-
-
-

Create Account

-
+ +
+
+
+
+
+
+
+
+
+
+
+
+ branding logo +
+
+
+
+
+

Create Account

-

Fill the below form to create a new account.

-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
- - - - - +
+

Fill the below form to create a new account.

+
+
+ +
+ ' required> + +
+
+ ' required> + +
+
+ ' required> + +
+
+ + +
+ +
+
+
+
+ + + + - I accept the terms & conditions. -
-
-
+ + I accept the terms & conditions. +
+
- Login -
+
+ Login +
-
+
+
-
- + + diff --git a/www/application/views/auth/view_reset_password.php b/www/application/views/auth/view_reset_password.php index 4b8aba4..28a8b20 100644 --- a/www/application/views/auth/view_reset_password.php +++ b/www/application/views/auth/view_reset_password.php @@ -45,7 +45,7 @@
diff --git a/www/application/views/member/view_securehead.php b/www/application/views/member/view_securehead.php index 1aa86ff..db70bef 100644 --- a/www/application/views/member/view_securehead.php +++ b/www/application/views/member/view_securehead.php @@ -205,7 +205,7 @@
John DoeAvailable
avatar