Welcome Guest, Not a member yet? Register   Sign In
Auth - auto loading model?
#1

[eluser]35mm[/eluser]
I'm building a user authentication system. It's a bespoke system as it has to sync with vBulletin forum and the site is fairly unique. Other than that it's just an auth system. I've made the login system which authenticates the user through the db with hashed and salted password, launches session and auth cookies, ads extra session info to db (as well as CI session) etc.

Now I need to authenticate the user as they move around the site by checking sessions and cookies and updating database etc. I'm new to CI, so I'm wondering how best to do this. I figure I need to do it within a model and have the model auto loaded - is that right? But then what's the most efficient way of communicating with the model so that views and controllers know if the user is authorised or not? Would I have to call the model from within every action in every controller? Or can views call the model directly? Or am I missing something? I am very tired after all z z z ~( ¦¬o)
#2

[eluser]Aken[/eluser]
Base controller (MY_Controller).
#3

[eluser]35mm[/eluser]
Thanks. I've had a look in the docs and on google, but not much info about basecontrollers. Any idea where I can find more details on using them?
#4

[eluser]Aken[/eluser]
I don't know how you can miss them, there are hundreds of references out there.
#5

[eluser]35mm[/eluser]
Yes I thought there might be something in the docs about it. I found some info on google and I used Phil Sturgeon's method using MY_Controller, Admin_Controller and Public_Controller. I have put all my auth checks (session, cookie, db) in a sessions model, and I'm passing an array of user vars (username, user_id etc) to MY_Controller, but how can I make those vars available to all child controllers? - google hasn't been much help there.
#6

[eluser]Aken[/eluser]
If you're assigning them as properties of a base controller, they'll be available to every controller that extends it. Basic OOP here.




Theme © iAndrew 2016 - Forum software by © MyBB