Skip to content

Commit 5a6b57f

Browse files
committed
auth login process fixed - new controller authindex
* the variables will be username and userclave, except in the DB table * changed all the links and references from `Login` to `IndexLogin/auth` * changed the menu logout reference to `Indexlogin/auth/logout` * changed the login referende in the Index point entry * remove the redundant detection of profiler debug view/class in controlles its already inherit from the core controller `CP_Controller` * implements `sessionficha` (creation by) and `sessionflag` (modified by) in the core controller as class variables (from DB/session) * improve the `datasession()` function with a writing flag detection in the core controller to determine if the user can manage rates * add the `$this->checksession();` in all controllers, but this will not logout the user, is just to check if user can write to the currency database and can change the rate currency values. * remove the `gemenu()` cos here we used the hardcoded menu from @radioactive99 so now he must manage a way to explain the menu footer * closes #14 from https://gitlab.com/codeigniterpower/codeigniter-currencylib/-/issues/14
1 parent eec48d6 commit 5a6b57f

File tree

12 files changed

+85
-221
lines changed

12 files changed

+85
-221
lines changed

cweb/elcurrencyweb/controllers/Currency_Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function __construct()
1717
{
1818
parent::__construct();
1919
$this->load->helper(array('form', 'url','html'));
20-
$this->output->enable_profiler(ENVIRONMENT !== 'production');
20+
$this->output->enable_profiler(FALSE); // set to true only to debug the json results api
2121
}
2222

2323

cweb/elcurrencyweb/controllers/Currency_Converter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function __construct()
1919
{
2020
parent::__construct();
2121
$this->load->helper(array('form', 'url','html'));
22-
$this->output->enable_profiler(ENVIRONMENT !== 'production');
22+
$this->checksession();
2323

2424
}
2525

cweb/elcurrencyweb/controllers/Currency_History.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class Currency_History extends CP_Controller {
1616
function __construct()
1717
{
1818
parent::__construct();
19-
$this->load->helper(array('form', 'url','html'));
20-
$this->output->enable_profiler(ENVIRONMENT !== 'production');
19+
$this->load->helper(array('form', 'url','html'));
20+
$this->checksession();
2121

2222
}
2323

cweb/elcurrencyweb/controllers/Currency_Manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function __construct()
1717
{
1818
parent::__construct();
1919
$this->load->helper(array('form', 'url','html'));
20-
$this->output->enable_profiler(ENVIRONMENT !== 'production');
20+
$this->checksession();
2121
}
2222

2323
/**

cweb/elcurrencyweb/controllers/Currency_Users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function __construct()
1818
{
1919
parent::__construct();
2020
$this->load->helper(array('form', 'url','html'));
21-
$this->output->enable_profiler(ENVIRONMENT !== 'production');
21+
$this->checksession();
2222
}
2323

2424
/**

cweb/elcurrencyweb/controllers/Home.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ function __construct()
1919
{
2020
parent::__construct();
2121
$this->load->helper(array('form', 'url','html'));
22-
$this->output->enable_profiler(ENVIRONMENT !== 'production');
23-
22+
$this->checksession();
2423
}
2524

2625
/**
@@ -33,7 +32,6 @@ function __construct()
3332
public function index()
3433
{
3534
$data = array();
36-
$data['menu'] = $this->genmenu();
3735
$data['currentctr'] = $this->currentctr;
3836
$data['currentinx'] = $this->currentinx;
3937
$data['currenturl'] = $this->currenturl;
Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,51 @@
11
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
22

3-
4-
class Indexauth extends YA_Controller {
3+
class Indexauth extends CP_Controller {
54

65
function __construct()
76
{
87
parent::__construct();
9-
$data['menu'] = $this->genmenu();
10-
$data['menusub'] = '';
11-
$this->data = $data;
128
}
139

14-
/**
15-
* index que muestra login para autenticacion, y verifica esta contra el modelo de datos
16-
* este controlador no necesita verirficar la session ya que este solo muestra si entra o no
17-
*
18-
* @name: index
19-
* @param void
20-
* @return void
21-
*/
22-
public function index($data = NULL)
10+
public function index($indexerror = NULL)
2311
{
12+
$data = array();
2413
$message = 'Auth system prepared';
25-
26-
if(is_array($data))
27-
{
28-
array_merge($this->data,$data);
29-
}
30-
else
14+
if( !is_array($indexerror) AND $indexerror != NULL)
3115
{
32-
if($data == 'autherror')
16+
if($indexerror == 'autherror')
3317
$message = 'Error login or invalid credentials';
34-
if($data == 'authcheck')
18+
if($indexerror == 'authcheck')
3519
$message = 'Invalid access or invalid credentials';
36-
if($data == 'logout')
20+
if($indexerror == 'logout')
3721
$message = 'Session closed';
38-
if($data == 'logauth')
39-
$message = 'Auth prepared to valid credentials';
40-
$data = $this->data;
22+
if($indexerror == 'logauth')
23+
$message = 'Ready again to valid credentials';
4124
}
42-
43-
$this->config->load('imap');
44-
$data['sitename'] = $this->config->item('imap_host');
45-
4625
$data['message'] = $message;
26+
$data['currentctr'] = $this->currentctr;
27+
$data['currentinx'] = $this->currentinx;
28+
$data['currenturl'] = $this->currenturl;
29+
$data['controllerlogin'] = 'Indexauth/auth/login';
30+
$data['userurl'] = $this->input->get_post('userurl');
4731
$this->load->view('header.php',$data);
48-
$this->load->view('inicion.php',$data);
32+
$this->load->view('login.php',$data);
4933
$this->load->view('footer.php',$data);
5034
}
5135

36+
/**
37+
* authenticator that uses action and user key credentials
38+
*
39+
* @name: auth
40+
* @param string $action logout|login
41+
* @param string $username the user email or login name
42+
* @param string $userclave the user password or user key api access
43+
* @return
44+
*
45+
*/
5246
public function auth($action = 'logout', $username = NULL, $userclave = NULL)
5347
{
54-
$typeerror = 'logout';
48+
$typeerror = 'nologin';
5549

5650
if($username == NULL)
5751
$username = $this->input->post('username');
@@ -63,29 +57,33 @@ public function auth($action = 'logout', $username = NULL, $userclave = NULL)
6357
$this->load->model('authmodel');
6458
$im_access = $this->authmodel->authimap($username, $userclave);
6559
$rs_access = $this->authmodel->authtable($username, $userclave);
60+
6661
if($im_access == FALSE)
6762
$typeerror = 'autherror';
6863
if($rs_access == FALSE)
6964
$typeerror = 'authcheck';
7065
}
7166

72-
if ( $action == 'logauth' )
73-
$typeerror = 'logauth';
67+
if ( $action == 'logauth' OR $action == 'logout' )
68+
$typeerror = $action;
7469

7570
$data = array();
76-
if($rs_access AND $im_access)
71+
if($rs_access != FALSE AND $im_access != FALSE)
7772
{
7873
$this->session->set_userdata('userdata', $rs_access);
79-
redirect('Index/vistainterna');
74+
redirect('Home');
8075
}
8176
else
8277
{
83-
$this->session->sess_destroy(); sleep(3);
84-
header('location:'.site_url('/Indexauth/index/'.$typeerror));
78+
$this->session->sess_destroy();
79+
if($action == 'logout')
80+
redirect('Index');
81+
else
82+
header('location:'.site_url('/Indexauth/index/'.$typeerror));
8583
}
8684
}
8785

8886
}
8987

90-
/* End of file Indexauth.php */
91-
/* Location: ./application/controllers/Indexauth.php */
88+
/* End of file welcome.php */
89+
/* Location: ./application/controllers/welcome.php */

cweb/elcurrencyweb/controllers/Login.php

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)