|
| 1 | +# codeigniter-login files |
| 2 | + |
| 3 | +## Database |
| 4 | + |
| 5 | +Since version 2.0.0 the project need a database connection, use the files |
| 6 | +at [webappdb](webappdb) directory. |
| 7 | + |
| 8 | +Until version 1.0.0 the check per se is made at the file `Indexauth.php` in the auth function.. |
| 9 | +the line of the variable `$rs_access` has the status.. if not TRUE or not NULL the check is passed. |
| 10 | + |
| 11 | +Since version 2.0.0 a database layer will be necessary so an extra file at `webappweb/models/Usersmodel.php` |
| 12 | +its necesary to provide functionality, and `$rs_access` is the result of the DB check. |
| 13 | + |
| 14 | +Since version 3.0.0 a imap mail layer was added so an extra files are at `webappweb/libraries/Imap.php` |
| 15 | +and `webappweb/config/imap.php`, `$im_access` is the result of the mail login check. |
| 16 | + |
| 17 | +Since version 4.0.0 a main controller do the check work of the sesion at `webappweb/core/CP_Controller.php` |
| 18 | +that all controllers inherit, so `$this->checksession();` is common functionality and reusable code. |
| 19 | + |
| 20 | +## Development |
| 21 | + |
| 22 | +The core core process is just 4 files, if you dont use the profiler neither database or imap auth: |
| 23 | + |
| 24 | +``` |
| 25 | + webappweb The Applicaions directory of Codeigniter renamed |
| 26 | + | |
| 27 | + /controllers Place of the controllers that manages logic |
| 28 | + | /Indexauth.php Login controller mechanish to init or end session |
| 29 | + | /Indexhome.php Another page entry, will check valid sesion object |
| 30 | + /views Pages display rendering data from controllers |
| 31 | + /homesview.php Arbitrary page only viewable under valid session |
| 32 | + /inicion.php Login view page for init the sesion process |
| 33 | +``` |
| 34 | + |
| 35 | +The complete implementation uses various files: |
| 36 | + |
| 37 | +* **webappweb** : this directory si the same as `application` of codeigniter |
| 38 | + framework, just renamed, if you want to use your own name just at `index.php` change |
| 39 | + the path of `$appication_folder` this directory has nothig to do with the login |
| 40 | + implementation, its just part of the example implementation if you want to test |
| 41 | + the hole project as unit. |
| 42 | +* **webappweb/controllers/Indexauth.php** Login controller mechanish, this class |
| 43 | + is a controller/route that will take the authentications actions and process them |
| 44 | + according to the type of "action", if the action is to "logout" it will invalidate |
| 45 | + the session, if the action is to "login", it will implement the logic you want |
| 46 | + against the desired data model. All throught the `auth` public method function. |
| 47 | +* **webappweb/controllers/Indexhome.php** Just arbitrary page entry, its provided |
| 48 | + to exemplify the authentication checks; while `Indexlogin` performs the authentication |
| 49 | + and exit, `Indexhome` represents any other that should only be seen under the |
| 50 | + active valid session, it represents controller/ruote that should always check |
| 51 | + the verified session. |
| 52 | +* **webappweb/core/CP_Controller.php** This class is the parent of the controllers, |
| 53 | + it has the `sessioncheck` method function with the session verification logic, |
| 54 | + the other controllers/routes when inheriting this will have the same code |
| 55 | + functionality of and with just one call into the inner controllers they can |
| 56 | + verify the session. This can be seen in the `Indexhome` controller (which check it |
| 57 | + before renders a normal page), while `Indexlogin` just represents a session entry |
| 58 | + or exit point (and do not check nothing). |
| 59 | +* **webappweb/views/homesview.php** This is the template view loaded by `Indexhome`, |
| 60 | + it will be rendered only if the login check in the controller will success. |
| 61 | + It represents an arbitrary page only viewable under valid session. |
| 62 | +* **webappweb/views/inicion.php** This is the template view loaded by the `Indexauth`, |
| 63 | + it will be rendered only if the login call if to make an auth as the controller |
| 64 | + said and the lagic of the `sessioncheck` function method determines. |
| 65 | + It represents a login view page for init the sesion process |
| 66 | +* **webappweb/models/Usersmodel.php** This class featured all the logic of |
| 67 | + the auth internal implementations, depending of you auth methods, will perform |
| 68 | + authenticacion agains mail (imap) of database (table), here you can added or |
| 69 | + improve your own methods of authentications. |
| 70 | +* **webappweb/libraries/Imap.php** This is a new class library for codeigniter, |
| 71 | + provided here as part of the project, this class permits to implement all the `imap` |
| 72 | + basic features from standard php imap module. It will be necesary for your |
| 73 | + implementation if you want to use imap mail login authentication from model. |
| 74 | + |
| 75 | +#### How to implement and not just copy files |
| 76 | + |
| 77 | +The first thing is and "auth" controller (here named `Indexauth.php`), grab the code |
| 78 | +of `auth` public method function and put it on your login controller/method. |
| 79 | + |
| 80 | +Inside the `auth` put or change the implementations, if you will made your own DB |
| 81 | +check just put a new model, call your DB check and load inthe this function. |
| 82 | + |
| 83 | +To fast forward the things you can grab the `Usersmodel.php` class that already has |
| 84 | +an database method check for authentication, and just change the DB access and table. |
| 85 | +This class has the real logic bussines of the login check. |
| 86 | + |
| 87 | +This is basically all the core process, with the explanation of each file previously |
| 88 | +you can improve a new authenticacion implementation inside codeigniter. |
| 89 | + |
| 90 | +#### Profiler and debugging |
| 91 | + |
| 92 | +Debugging is using our profiler, it requires a special view which is not part of the project |
| 93 | +so it is provided as an extra file in the [vendor](vendor) directory, just take it and put it on |
| 94 | +the views directory and profiler will work. |
| 95 | + |
| 96 | +Until version 3.9.9 it can be simply disabled in the controller constructor, since version 4.0.0 |
| 97 | +it is disabled in the core controller constructor inherited by the other controllers. |
| 98 | + |
| 99 | +#### Process simple login |
| 100 | + |
| 101 | +This is the main entry controller, it will load the views of login form page |
| 102 | +to input credentials, also will process such request to validate the login |
| 103 | +process of the credentials. |
| 104 | + |
| 105 | +``` |
| 106 | +->user/pass--->Indexauth/index--->Indexauth/auth()---->Indexhome/index (sucess) |
| 107 | + (check) | |
| 108 | + |---->Indexauth/index (fail) |
| 109 | +``` |
| 110 | + |
| 111 | +The magic is done by the `auth($data = NULL, ... , ... )` |
| 112 | + |
| 113 | +## Authors and acknowledgment |
| 114 | + |
| 115 | +Show your appreciation to those who have contributed to the project. |
| 116 | + |
| 117 | +## License |
| 118 | + |
| 119 | +For open source projects, say how it is licensed. |
| 120 | + |
| 121 | +## Project status |
| 122 | + |
| 123 | +If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. |
0 commit comments