On Tuesday, April 2, 2013 4:47:39 AM UTC-4, Vinicius Dusso wrote:
Hi Nathan,--I've just finished setting up my project with separated auths.Here is basically what I did:In AppController, created a method to setup Auth Configurations:private function setAuthType($type) {switch ($type) {case "admin":$sessionKey = 'Auth.Admin.User';$username = 'email';$password = 'password';$userModel = 'User';$displayField = 'email';$authType = 'Form';break;case "user":$sessionKey = 'Auth.User';$username = 'email';$password = 'password';$userModel = 'Member';$displayField = 'email';$authType = 'Form';break;}AuthComponent::$sessionKey = $sessionKey;$this->Auth->authenticate = array($authType => array('fields' => array('username' => $username,'password' => $password),'userModel' => $userModel));$this->Auth->authorize['Actions']['userModel'] = $userModel; }The AuthComponent allows you to define which will be your UserModel and wich will be your SessionKey.You can get the current user simply using the method $this->Auth->user();This way you can check if its an user or a student.Hope it helps!Best Regards,Vinicius
On Monday, April 1, 2013 4:18:06 PM UTC-3, Nathan Pierce wrote:Hey y'all, I got a question.I've got the registration form for my site putting stuff in the database, but I'm wondering if someone has any suggestions on how I can achieve some features.1. I'm going to have a table for teachers and students. They will have two separate login forms on the site, one more simple than the other. I'm focusing on students right now, since it's using the UsersController, etc. I'm just wondering if someone has any suggestion on using cakephp and having two separate auth systems. Is there some documentation somewhere about this? I want two separate tables in the database, I don't want all users in one giant ass database table and then having roles, etc.2. I need a way to identify student login sessions from teachers sessions so I can do some if logic and send them to the proper dashboard/etc. I'm new to cake, so I'm wondering if there is a best method someone can suggest to me. I'm trying to keep things standard to cake, which will be impossible, but I'm still trying. I'm guessing I need to assign a role to the user when they signup and then just use that. Right? Or should I use another system to do this and have them all in one database? I'd really like them split up..Thanks for your time!
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment