Re: Auth->login() Not working correctly?

2008-12-09 Thread gearvOsh

Ya but my Auth isnt redirecting itself, not sure if its supposed to. I
could just do a manual if statement though.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-09 Thread Milmar

On Dec 10, 6:03 am, gearvOsh <[EMAIL PROTECTED]> wrote:
> I found out the problem after much debugging and stress. I was using
> an old db that didnt use a salted password HENCE thats why it would
> not login because it was adding the salt to the passwords. So when I
> removed the salt it worked. Something like that should be noted in the
> cookbook.

That's great. I experienced this pitfall once too (I added the salt in
core.php AFTER I saved the passwords in the DB that's why the
passwords were not matching).


> Also, if you are logged in, should you NOT be able to go to the login
> page?

-I think this is the best way of doing it. If you're already logged,
you should be automatically redirected to your user page when you try
to access the login page.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-09 Thread gearvOsh

I found out the problem after much debugging and stress. I was using
an old db that didnt use a salted password HENCE thats why it would
not login because it was adding the salt to the passwords. So when I
removed the salt it worked. Something like that should be noted in the
cookbook.

Also, if you are logged in, should you NOT be able to go to the login
page?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-09 Thread jim.west

Hey,

Although Milmar gave you most of what you need, i've written a small
blog post about how I did it all, when I first tackled the Auth
component: 
http://westsworld.dk/posts/view/cakephp-and-the-_in_-famous-auth-component

Still, i'd say, that you should leave the login() function blank. Cake
should then be able to do it's magic. I think it doesn't override your
method, if you've implemented it. (Haven't checked this though)

Hope you can use it.

On Dec 9, 6:22 am, gearvOsh <[EMAIL PROTECTED]> wrote:
> Here is my AppController and my UsersController:
>
> class AppController extends Controller {
>
>         var $components = array('Auth');
>
>         function beforeFilter() {
>                 Security::setHash('md5');
>
>                 // Authenticate
>                 $this->Auth->sessionKey = 'User';
>                 //$this->Auth->authorize = 'controller';
>                 $this->Auth->loginAction = array('controller' => 'users', 
> 'action'
> => 'login');
>                 $this->Auth->loginRedirect = $referer;
>                 $this->Auth->logoutRedirect = array('controller' => 'site', 
> 'action'
> => 'index', 'home');
>         }
>
> }
>
> class UsersController extends AppController {
>
>         function index() {
>                 $this->redirect(array('controller' => 'users', 'action' =>
> 'login'));
>         }
>
>         /**
>          * Login
>          */
>         function login() {
>                 $this->pageTitle = 'Login - GameSync';
>                 $this->set('activeTab', 'login');
>         }
>
>         /**
>          * Logout
>          */
>         function logout() {
>                 $this->redirect($this->Auth->logout());
>         }
>
> }

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-08 Thread gearvOsh

Here is my AppController and my UsersController:

class AppController extends Controller {

var $components = array('Auth');

function beforeFilter() {
Security::setHash('md5');

// Authenticate
$this->Auth->sessionKey = 'User';
//$this->Auth->authorize = 'controller';
$this->Auth->loginAction = array('controller' => 'users', 
'action'
=> 'login');
$this->Auth->loginRedirect = $referer;
$this->Auth->logoutRedirect = array('controller' => 'site', 
'action'
=> 'index', 'home');
}
}

class UsersController extends AppController {

function index() {
$this->redirect(array('controller' => 'users', 'action' =>
'login'));
}

/**
 * Login
 */
function login() {
$this->pageTitle = 'Login - GameSync';
$this->set('activeTab', 'login');
}

/**
 * Logout
 */
function logout() {
$this->redirect($this->Auth->logout());
}
}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-08 Thread Milmar

Did you create any other customization for login/logout together with
the code posted above? If yes, then post the code here so that we can
see.

For the beforeFilter() function, I think you no longer need to check
for the referer and for  isset(($this->Auth) (Assuming Auth is already
included in var $components). You can directly assign array
('controller' => 'dashboard', 'action' => 'index'); to $this->Auth-
>loginRedirect.

If you're going to use $this->Auth->authorize = 'controller';  (I see
it's commented out), then you will need to implement the isAuthorized
() function for app_controller.php as well.

Can you try putting $this->Auth->allow('*'); in beforeFilter(),  then
check if it redirects to the dashboard index when you login.




On Dec 8, 1:56 pm, gearvOsh <[EMAIL PROTECTED]> wrote:
> Actually nevermind. The $this->data had to be under User, not Form.
> Now the login is submitting and the query is being fired... BUT now
> everytime I hit login the password field goes empty and it never
> works.
>
> On Dec 7, 9:50 pm, gearvOsh <[EMAIL PROTECTED]> wrote:
>
> > I tried removing the $this->Auth->login() and now it doesnt do
> > anything. No query is fired.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-07 Thread gearvOsh

Actually nevermind. The $this->data had to be under User, not Form.
Now the login is submitting and the query is being fired... BUT now
everytime I hit login the password field goes empty and it never
works.

On Dec 7, 9:50 pm, gearvOsh <[EMAIL PROTECTED]> wrote:
> I tried removing the $this->Auth->login() and now it doesnt do
> anything. No query is fired.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-07 Thread gearvOsh

I tried removing the $this->Auth->login() and now it doesnt do
anything. No query is fired.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-07 Thread Drew Pearson

try not putting anything in the login action. It does what you are  
trying to do automatically. You also don't need to redirect to the  
referrer as the Auth component stores this automatically. The Auth  
component also looks for logout in a new action logout. Thats where to  
put your redirect.

Also make sure the password you stored in your database is the hashed  
version. You can view a hash result by putting  echo $this->Auth- 
 >password("password string here"); in an action.

On Dec 7, 2008, at 6:15 PM, gearvOsh wrote:

>
> So im trying to get the Auth component to work, here is my
> AppController.
>
> function beforeFilter() {
> // Referer
> $referer = $this->referer(null, true);
> if (empty($referer)) {
>   $referer = array('controller' => 'dashboard', 'action' => 'index');
> }
>
> // Authenticate
> if (isset($this->Auth)) {
>   $this->Auth->sessionKey = 'User';
>   //$this->Auth->authorize = 'controller';
>   $this->Auth->loginAction = array('controller' => 'users', 'action' =>
> 'login');
>   $this->Auth->loginRedirect = $referer;
>   $this->Auth->logoutRedirect = array('controller' => 'site', 'action'
> => 'index', 'home');
> }
> }
>
> That all works fine, its just when I submit my login form (users/
> login), the password field does not get encrypted, so it never finds
> any rows. I read the docs and it said that it should auto-encrypt any
> field named password, obviously its not.
>
> Login action:
>
> // Form processing
> if (!empty($this->data)) {
>   $this->Auth->login($this->data['Form']);
> }
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth->login() Not working correctly?

2008-12-07 Thread gearvOsh

Also heres a debug of $this->data:

Array
(
[Form] => Array
(
[username] => test123
[password] => pass123
)

)

And the query being run by $this->Auth->login():

SELECT `User`.`id`, `User`.`username`, `User`.`password`  FROM
`users` AS `User` WHERE `User`.`username` = 'test123' AND
`User`.`password` = 'pass123' LIMIT 1
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---