Howto make a login/auth .. thing ;) |
[eluser]DynamiteN[/eluser]
Hi, i have started to use Matchbox and was wondering how i should go about when i want to make .. i guess a login/member controller... i have my main controller in "modules/home/controllers/main.php" this is then the main controller (the default) Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Code: <?php $this->load->view('inc/header'); //including the header that's in "views/inc" folder ?> and this to include the footer Code: <?php $this->load->view('inc/footer'); //including the footer that's in "views/inc" folder ?> in my header i then include a file called "user_view" that also resides in the "views/inc" folder Code: <?php $this->load->view('inc/user_view'); ?> the thing is i just dont know where to start or how to do exactly, i have looked at those different libraries for auth and such in the wiki. but feel like i would benefit much more if i get to experiment and find out how do it for my self from scratch and hopefully in the end get a app that i am satisfied with and know exactly what it does and so fourth... if anyone has any ideas or useful links with some tutorials where i can learn more about this, i've been looking alot on different sites and following tutorials, but there really aint that much just about this :/.. Thanks for any help at all ..
[eluser]Jacob Krustchinsky[/eluser]
Ill give you a quick outline, but in order to learn it entirely I would recommend http://net.tutsplus.com/tutorials/php/us...-with-php/ as an article to understand the logic and then apply it to codeigniter. Make an auth controller and an auth model. Auth controller: Auth() index() register() login() logout() This controller will handle all of the basic stuff. Utilize the form validation class to make your job easier. Auth model: Basic CRUD model, addUser(), editUser(), deleteUser(), getUserInfo() etc. You could even add a library to handle some simple checks to clean up your code, like.. $this->auth_check->isAdmin() or $this->auth_check->isUser()
[eluser]DynamiteN[/eluser]
Thx for replying, ye i really needed to be reminded of the logic there in that tut, as it is easy to overthink alot when trying all new stuff thx ye i figured i would have to make some sort of a controller to handle som basic stuff, im gonna giva it a new try tomorow when i have had a good night sleep Also, i forgot to ask this question in the first post. as i am using matchbox so i use modules i was wondering is it possible if i would be able to something like this: -modules --home --auth/members ---controllers ----/login ----/register have a complete seperate module called something like "auth" or "members" or something where all controllers about logging in -out , registering, adn all that stuff are?? and then somehow use them in the other modules such as the "home" reason i'm wondering is that i would really like to have all that have to do with the auth part of the site in one place and all the other modules then use the function and such from that module this is so i can be a bit orginased and i am planning to do a admin module where i then manage the whole site, and it would be nice not have to pretty much use duplicates of of controller in every module instead i would then use the controller adn function from the auth module in the admin/backend module hope everything made sence, as im a bit tired thankful for any ideas on that... but will definetly try to do a small app first to experiment but first some sleep thx for helping
[eluser]pbreit[/eluser]
You might want to check "Modular Separation" which is the successor to Matchbox. And Ion Auth is a nice, lean auth library.
[eluser]DynamiteN[/eluser]
[quote author="pbreit" date="1280138918"]You might want to check "Modular Separation" which is the successor to Matchbox. And Ion Auth is a nice, lean auth library.[/quote] i will check out Modular Separation but as fir the Ion Auth, i am trying to do my own , this way in the end i will have it the way exactly as i want
[eluser]pbreit[/eluser]
Yeah, I was thinking even if you roll your own, it's nice to look at a good example. Another even simpler example is QuickAuth.
[eluser]DynamiteN[/eluser]
k , well i've been trying to look at some of the other auth libraries and such, but most of them i just can't seem to wrap my head around, but i will be trying everydaty until my brain spins up to the right speed not much seem to get stuck now a days, but thx for bringing ideas as i really need 'em
[eluser]pbreit[/eluser]
I know exactly what you mean. And it didn't help that I put the wrong name in. I was actually referring to QuickAuth which is very simple and easy to follow: http://www.daveblencowe.com/2010/quickauth-v2-0/ Ion Auth has quite a few more features but is still pretty easy to understand.
[eluser]DynamiteN[/eluser]
[quote author="pbreit" date="1280195622"]I know exactly what you mean. And it didn't help that I put the wrong name in. I was actually referring to QuickAuth which is very simple and easy to follow: http://www.daveblencowe.com/2010/quickauth-v2-0/ Ion Auth has quite a few more features but is still pretty easy to understand.[/quote] ye , i do understand about half of it when i look at some of the code, but as soon as i'm gonna try to start my own and open up the editor just about to write something it all just freezez for me, i just can't get started on writing anything , jsut so frustrating, think i am gonna go start all over from the basics or something... so that i actually can finish my project
[eluser]DynamiteN[/eluser]
okey, so now i have managed to get somewhere i trhew out the modules for now so that i can focus on this login auth thing so i found a really easy tut over at bramme.net, and stripped some of it so that i can make it my own and build on it libraries/auth.php : Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); and the member_model that does the query models/member_model.php : Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?> and then i put this in my controller controllers/site.php : Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); and it works... sort of... when i go login enter username and password it processes it and i go back to the index function (first page) and in my header view i have put this Code: <?php if($this->auth->logged_in()) : ?> the problem is that i cant get it to show the username of the logged in person. When i am logged out i only see the login link. And when i am logged in i se my logout button, but i do not know what to do to make the username and stuff show :/ any help on this would be really helpful P.S i also tried to have the session stored in database but no change in the result, works exactly the same ... |
Welcome Guest, Not a member yet? Register Sign In |