Skip to content

Commit 0280c25

Browse files
committed
RELEASE 3.0.0 now with mail login support and double check to DB layer
* check first at imap auth using a stream imap object, this is pretty bad for slow connections but usefull as didacticall learning * now we check both imap and database for the user * imap mail must be configured in the config/imap.php file, mayor mail providers use special ways and may not work.
1 parent 0702be5 commit 0280c25

File tree

5 files changed

+1641
-14
lines changed

5 files changed

+1641
-14
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ the line of the variable `$rs_access` has the status.. if are not TRUE or not NU
6262
Since version 2.0.0 a database layer will be necessary so an extra file at `webappweb/models/Usersmodel.php`
6363
its necesary to provide functionality, and `$rs_access` is the result of the DB check.
6464

65+
Since version 3.0.0 a imap mail layer was added so an extra files are at `webappweb/libraries/Imap.php`
66+
and `webappweb/config/imap.php`, `$im_access` is the result of the mail login check.
67+
6568
#### Process simple login
6669

6770
This is the main entry controller, it will load the views of login form page

webappweb/config/imap.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
defined('BASEPATH') || exit('No direct script access allowed');
3+
4+
$config['imap_secu'] = 'tls';
5+
$config['imap_cert'] = FALSE;
6+
$config['imap_host'] = 'mydomainofmail.com';
7+
$config['imap_port'] = 143;
8+
$config['imap_user'] = NULL;
9+
$config['imap_pass'] = NULL;
10+
11+
$config['imap_folders'] = [
12+
'inbox' => 'INBOX',
13+
'sent' => 'Sent',
14+
'trash' => 'Trash',
15+
'spam' => 'Spam',
16+
'drafts' => 'Drafts',
17+
];
18+
19+
$config['expunge_on_disconnect'] = FALSE;
20+
21+
$config['imap_cache'] = [
22+
'active' => FALSE,
23+
'adapter' => 'file',
24+
'backup' => 'file',
25+
'key_prefix' => 'imap:',
26+
'ttl' => 60,
27+
];

webappweb/controllers/Indexauth.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ public function auth($action = 'logout', $username = NULL, $userclave = NULL)
3232
if ( $action == 'login' )
3333
{
3434
$this->load->model('usersmodel');
35-
$rs_access = $this->usersmodel->login($username, $userclave);
35+
36+
$im_access = $this->usersmodel->loginimap($username, $userclave);
37+
38+
$rs_access = $this->usersmodel->logindb($username, $userclave);
3639
}
3740

3841
$data = array();
3942
$message = 'Invalid login parameters or session ended';
40-
if($rs_access)
43+
if($rs_access AND $im_access)
4144
{
4245
$message = 'Session initialized';
4346
$viewtitle = 'index at Pagetest';

0 commit comments

Comments
 (0)