I'm getting stuck with login page in cakephp 2.4

2015-11-27 Thread Nguyễn Quang Nhân
Hi everyone, I'm getting stuck with login page in cakephp 2.4, can anyone 
help me figure it out what mistakes I have made. Thank you so much!
(why did I dont see the password in WHERE clause of the query??)

Here is sql file, the project file and two pictures describe the problem: 
- SQL file: 
https://www.dropbox.com/s/b4pv419j09rp5jk/chickenrainshop.sql?dl=0

- Project file: 
https://www.dropbox.com/s/kextdrpzizyskwd/chickenrainshop.zip?dl=0

<https://lh3.googleusercontent.com/-UQ3yLfooRtc/VlhOl_xA5qI/BUY/9pwRyf_F3V4/s1600/Untitled.png>


<https://lh3.googleusercontent.com/-RJZ5x7aN23Q/VlhOpocRGRI/BUg/lJ-4g8fiK4o/s1600/Untitled2.png>



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3.1: Login with Username or Email?

2015-09-25 Thread John Andersen
Goodle it:
http://stackoverflow.com/questions/30648852/login-with-username-or-email-with-cakephp-3

On Friday, 25 September 2015 22:07:19 UTC+3, Salines wrote:
>
> Can any of the core CakePHP developers explain to us in what manner we can 
> perform user authentication with username or email plus password.
>
> Thank you.
>

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


CakePHP 3.1: Login with Username or Email?

2015-09-25 Thread Salines
Can any of the core CakePHP developers explain to us in what manner we can 
perform user authentication with username or email plus password.

Thank you.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: if($this->Auth->login($this->request->data)) Return true with right or wrong password and iden

2015-09-21 Thread euromark
Read the documentation.
You are never supposed to pass anything to login() in this case.

mark


Am Samstag, 19. September 2015 22:11:47 UTC+2 schrieb abdessamad kassasse:
>
> i will show my code
> utilisateurcontroller
> public function login()
> {
> debug($this->Session->read());
> if($this->request->is('post'))
> {
> print_r($this->request->data);
> if($this->Auth->login($this->request->data))
> { 
> debug($this->Auth->login($this->request->data)); 
> debug($this->Auth->user()); 
> echo "**";
> //return $this->redirect($this->Auth->redirectUrl());
> }
> else{
>
> echo 
> "";
> $this->Session->setFlash(__('Invalid name_U or password'));
>
> }
> }
> 
> /*if ($this->Session->read('Auth.Utilisateur')) {
> $this->Session->setFlash('Vous êtes connecté!');
> return $this->redirect('/');
> echo $this->Session->flash('auth');
> }*/
>
> }
> public function logout()
> {
> $this->Auth->logout();
>  $this->Session->destroy();
> $this->redirect('/clients/index');
> }
>
> -
> model
>  App::uses('AppModel', 'Model');
> /**
>  * Utilisateur Model
>  *
>  * @property Group $Group
>  */
> App::uses('AuthComponent', 'Controller/Component');
> class Utilisateur extends AppModel {
>
> /**
>  * Display field
>  *
>  * @var string
>  */
> public $displayField = 'id';
>
>
> //The Associations below have been created with all possible keys, 
> those that are not needed can be removed
>
> /**
>  * belongsTo associations
>  *
>  * @var array
>  */
> public $belongsTo = array(
> 'Group' => array(
> 'className' => 'Group',
> 'foreignKey' => 'group_id',
> 'conditions' => '',
> 'fields' => '',
> 'order' => ''
> )
> );
>
>
> public $actsAs = array('Acl' => array('type' => 'requester', 'enabled' 
> => false));
>
> public function parentNode() {
> if (!$this->id && empty($this->data)) {
> return null;
> }
> if (isset($this->data['Utilisateur']['group_id'])) {
> $groupId = $this->data['Utilisateur']['group_id'];
> } else {
> $groupId = $this->field('group_id');
> }
> if (!$groupId) {
> return null;
> }
> return array('Group' => array('id' => $groupId));
> }
> public function beforeSave($options = array()) {
> $this->data['Utilisateur']['password'] = 
> AuthComponent::password($this->data['Utilisateur']['password']);
> return true;
> }
> public function bindNode($utilisateur) {
>
> return array('model' => 'Group', 'foreign_key' => 
> $utilisateur['Utilisateur']['group_id']);
> }
>
> }
>
> -
> app controller
>  /**
>  * Application level Controller
>  *
>  * This file is application-wide controller file. You can put all
>  * application-wide controller-related methods here.
>  *
>  * @link  http://cakephp.org CakePHP(tm) Project
>  * @package   app.Controller
>  * @since CakePHP(tm) v 0.2.9
>  */
>
> App::uses('Controller', 'Controller');
>
> /**
>  * Application Controller
>  *
>  * Add your application-wide methods in the class below, your controllers
>  * will inherit them.
>  *
>  * @packageapp.Controller
>  * @link
> http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
>  */
> class AppController extends Controller {
> public $helpers =array('Html','Form','Session');
>
> public $components = array('Session','Acl',
> 'Auth' => array(
> 'authorize' => array(
> 'Actions' => array('actionPath' => 'controllers',
>   'userModel' => 'Utilisateur'),
> 
> 'authenticate'=>array('Form'=>array('fields'=>array('username'=>'name_U','password'=>'password')))
>  
> 

if($this->Auth->login($this->request->data)) Return true with right or wrong password and iden

2015-09-19 Thread abdessamad kassasse
i will show my code
utilisateurcontroller
public function login()
{
debug($this->Session->read());
if($this->request->is('post'))
{
print_r($this->request->data);
    if($this->Auth->login($this->request->data))
{ 
    debug($this->Auth->login($this->request->data)); 
debug($this->Auth->user()); 
echo "**";
//return $this->redirect($this->Auth->redirectUrl());
}
else{

echo "";
$this->Session->setFlash(__('Invalid name_U or password'));

}
}

/*if ($this->Session->read('Auth.Utilisateur')) {
$this->Session->setFlash('Vous êtes connecté!');
return $this->redirect('/');
echo $this->Session->flash('auth');
}*/

}
public function logout()
{
$this->Auth->logout();
 $this->Session->destroy();
$this->redirect('/clients/index');
}
-
model
 array(
'className' => 'Group',
'foreignKey' => 'group_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);

   
public $actsAs = array('Acl' => array('type' => 'requester', 'enabled' 
=> false));

public function parentNode() {
if (!$this->id && empty($this->data)) {
return null;
}
if (isset($this->data['Utilisateur']['group_id'])) {
$groupId = $this->data['Utilisateur']['group_id'];
} else {
$groupId = $this->field('group_id');
}
if (!$groupId) {
return null;
}
return array('Group' => array('id' => $groupId));
}
public function beforeSave($options = array()) {
$this->data['Utilisateur']['password'] = 
AuthComponent::password($this->data['Utilisateur']['password']);
return true;
}
public function bindNode($utilisateur) {

return array('model' => 'Group', 'foreign_key' => 
$utilisateur['Utilisateur']['group_id']);
}

}
-
app controller
http://cakephp.org CakePHP(tm) Project
 * @package   app.Controller
 * @since CakePHP(tm) v 0.2.9
 */

App::uses('Controller', 'Controller');

/**
 * Application Controller
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @packageapp.Controller
 * @link
http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
 */
class AppController extends Controller {
public $helpers =array('Html','Form','Session');

public $components = array('Session','Acl',
'Auth' => array(
'authorize' => array(
'Actions' => array('actionPath' => 'controllers',
  'userModel' => 'Utilisateur'),

'authenticate'=>array('Form'=>array('fields'=>array('username'=>'name_U','password'=>'password')))
 
)

   
   )
  

 );

 public function beforeFilter() {
 $this->Auth->allow('display');
 $this->Auth->userModel = 'Utilisateur';


   $this->Auth->loginAction = array(
  'controller' => 'Utilisateurs',
  'action' => 'login'
);
$this->Auth->logoutRedirect = array(
  'controller' => 'Utilisateurs',
  'action' => 'login'
);
  /*  $this->Auth->loginRedirect = array(
  'controller' => 'Utilisateurs',
  'action' => 'add'
);*/
$this->Auth->fields = array(
'username' => 'name_U',
    'password' => 'password'
);
 

 }
}
?>

login.ctp





 

Login 
  


   
Form->create('Utilisateur',array('class'=>'form-horizontal 
form-label-left'));
?>

Form->input("name_U",array('div'=>'col-md-6 col-sm-6 
col-xs-12','label'=>array('text'=>'Name','class'=>'control-label col-md-1 
col-sm-1 col-xs-12'),'class'=>'form-control col

how to use httpAutentication for login process

2015-09-14 Thread Jack Kalish


My question is I have two url In my one url I was write below code for 
login process

 if($this->request->is('post')){

  $HttpSocket = new HttpSocket();
  $HttpSocket->configAuth('Basic', 'username', 'password');
  $response = $HttpSocket->get('http://localhost/cake2/Tests/login');

ORIn Client Method

 $http = new Client();
 $response = $http->get('http://localhost/cake2/Tests/login', [], ['auth' => 
['username' => 'myusername', 'password' => 'mypassword']
 ]);
}
then how to get username and password in second url using HttpAuthentication 
method in cakphp

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Cakephp Login form with different database tables

2015-08-07 Thread Gaurav Kumar
Your distributors login submit looking for a 'distributor_login' method and 
that is missing 'DistributorsController'.

On Friday, July 31, 2015 at 4:54:16 PM UTC+5:30, Asmat Quadeer wrote:

 I am trying to create a login form for different types of users like

 `Suppliers`, `Distributors`, `Managers`


 on the website like

 http://azzip.de/distributors/login

 And the Distributor's beforeFilter looks like

 
 public function beforeFilter() {
 
 parent::beforeFilter();
 
 AuthComponent::$sessionKey = 'Auth.Distributor';
 
 $this-Auth-authenticate = array(
 'Form' = array(
 'userModel' = 'Distributor',
 'fields' = array(
 'username' = 'email',
 'password' = 'password'
 ),
 'scope' = array(
 'Distributor.active' = 1,
 )
 )
 );
 
 $this-Auth-allow('login', 'forgotpass', 'register');
 }


 The passwords are hashed. But no chance to login. and unfortunately also 
 can't see the the 
 `login()`

 query to debug. 



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Cakephp Login form with different database tables

2015-07-31 Thread Asmat Quadeer
I am trying to create a login form for different types of users like

`Suppliers`, `Distributors`, `Managers`


on the website like

http://azzip.de/distributors/login

And the Distributor's beforeFilter looks like


public function beforeFilter() {

parent::beforeFilter();

AuthComponent::$sessionKey = 'Auth.Distributor';

$this-Auth-authenticate = array(
'Form' = array(
'userModel' = 'Distributor',
'fields' = array(
'username' = 'email',
'password' = 'password'
),
'scope' = array(
'Distributor.active' = 1,
)
)
);

$this-Auth-allow('login', 'forgotpass', 'register');
}


The passwords are hashed. But no chance to login. and unfortunately also 
can't see the the 
`login()`

query to debug. 

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3 - Login form not working

2015-07-22 Thread 'Sajoscha Sauer' via CakePHP
Hi, 

Did you make sure that the password column in your database is long enough for 
a hashed password? 

Otherwise your code looks fine and should actually work, I guess. 

Cheers, 
Sajoscha

 On Jul 20, 2015, at 9:33 PM, Mark Dijkema mark.dijk...@gmail.com wrote:
 
 I am following both the tutorials in the CakePHP 3 documentation and I am 
 trying to get the login functionality working, but so far I have no luck.
 I have a Users table with the 2 fields 'username' and 'password'. The 
 password is hashed with `(new DefaultPasswordHasher)-hash($password);`
 
 After I enter the username and password, I do get into the login function, 
 but the `$this-Auth-identify();` never returns an user.
 The post data is filled, but the password is not hashed yet. I assume this 
 happens in `$this-Auth-identify();`?
 
 Could anyone tell me what I ma doing wrong? I am not getting any errors I 
 could work with.
 
 I have the following form:
 ?php
 if(!is_null($this-request-session()-read('Auth.User.username')))
 {
 echo 'logged in';
 }
 else
 {
 echo $this-Form-create('User', array('action' = 'login'));
 echo $this-Form-input('username', [
 'class' = 'w3-input',
 'placeholder' = 'username',
 'label' = false
 ]);
 echo $this-Form-input('password', [
 'class' = 'w3-input',
 'placeholder' = 'password',
 'label' = false
 ]);
 echo $this-Form-button('Login', [
 'class' = 'w3-btn'
 ]);
 echo $this-Form-end();
 }
 ?
 
 this is my AppController:
 public function initialize()
 {
 parent::initialize();
 $this-loadComponent('Flash');
 $this-loadComponent('Auth', [
 'scope' = [
 'Users.active' = 1
 ],
 'authenticate' = [
 'Form' = [
 'fields' = [
 'username' = 'username',
 'password' = 'password'
 ]
 ]
 ],
 'loginAction' = [
 'controller' = 'Users',
 'action' = 'login'
 ],
 'logoutRedirect' = [
 'controller' = 'Users',
 'action' = 'homepage'
 ]
 ]);
 
 $this-layout = 'creed';
 }
 
 In the query it uses (she bottom of post), it never uses the scope at all or 
 the password field.
 
 And this is my login function:
 
 public function login()
 {
 if($this-request-is('post'))
 {
 $user = $this-Auth-identify();
 if($user)
 {
 $this-Auth-setUser($user);
 
 return $this-redirect($this-Auth-redirectUrl());
 }
 }
 }
 
 
 This is the query that is being used in the login function
 SELECT `Users`.`id` AS `Users__id`,
 `Users`.`username` AS `Users__username`, 
 `Users`.`password` AS `Users__password`,
 `Users`.`email` AS `Users__email`,
 `Users`.`level` AS `Users__level`,
 `Users`.`image` AS `Users__image`,
 `Users`.`signature` AS `Users__signature`,
 `Users`.`active` AS `Users__active`,
 `Users`.`date_joined` AS `Users__date_joined`
 FROM `users` `Users`
 WHERE `Users`.`username` = 'DijkeMark'
 LIMIT 1
 
 
 This returns 1 result, because there is a user in the DB with this name. But 
 the password field is not being used.
 
 I also baked the Entity and the Table file, so that should be correct too. I 
 really start to hate CakePHP and it's authentication system, because I have 
 done everything I am supposed to do and it gives not a single error on what I 
 am doing wrong.
 
 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP 
 https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP 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+unsubscr...@googlegroups.com 
 mailto:cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com 
 mailto:cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php 
 http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout 
 https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http

CakePHP 3 - Login form not working

2015-07-21 Thread Mark Dijkema
I am following both the tutorials in the CakePHP 3 documentation and I am 
trying to get the login functionality working, but so far I have no luck.
I have a Users table with the 2 fields 'username' and 'password'. The 
password is hashed with `(new DefaultPasswordHasher)-hash($password);`

After I enter the username and password, I do get into the login function, 
but the `$this-Auth-identify();` never returns an user.
The post data is filled, but the password is not hashed yet. I assume this 
happens in `$this-Auth-identify();`?

Could anyone tell me what I ma doing wrong? I am not getting any errors I 
could work with.

I have the following form:
?php
if(!is_null($this-request-session()-read('Auth.User.username')))
{
echo 'logged in';
}
else
{
echo $this-Form-create('User', array('action' = 'login'));
echo $this-Form-input('username', [
'class' = 'w3-input',
'placeholder' = 'username',
'label' = false
]);
echo $this-Form-input('password', [
'class' = 'w3-input',
'placeholder' = 'password',
'label' = false
]);
echo $this-Form-button('Login', [
'class' = 'w3-btn'
]);
echo $this-Form-end();
}
?

this is my AppController:
public function initialize()
{
parent::initialize();
$this-loadComponent('Flash');
$this-loadComponent('Auth', [
'scope' = [
'Users.active' = 1
],
'authenticate' = [
'Form' = [
'fields' = [
'username' = 'username',
'password' = 'password'
]
]
],
'loginAction' = [
'controller' = 'Users',
'action' = 'login'
],
'logoutRedirect' = [
'controller' = 'Users',
'action' = 'homepage'
]
]);

$this-layout = 'creed';
}

In the query it uses (she bottom of post), it never uses the scope at all 
or the password field.

And this is my login function:

public function login()
{
if($this-request-is('post'))
{
$user = $this-Auth-identify();
if($user)
{
$this-Auth-setUser($user);

return $this-redirect($this-Auth-redirectUrl());
}
}
}


This is the query that is being used in the login function
SELECT `Users`.`id` AS `Users__id`,
`Users`.`username` AS `Users__username`, 
`Users`.`password` AS `Users__password`,
`Users`.`email` AS `Users__email`,
`Users`.`level` AS `Users__level`,
`Users`.`image` AS `Users__image`,
`Users`.`signature` AS `Users__signature`,
`Users`.`active` AS `Users__active`,
`Users`.`date_joined` AS `Users__date_joined`
FROM `users` `Users`
WHERE `Users`.`username` = 'DijkeMark'
LIMIT 1


This returns 1 result, because there is a user in the DB with this name. 
But the password field is not being used.

I also baked the Entity and the Table file, so that should be correct too. 
I really start to hate CakePHP and it's authentication system, because I 
have done everything I am supposed to do and it gives not a single error on 
what I am doing wrong.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: How to create Login using already-hashed password from another application (non-cakephp application)

2015-06-25 Thread chol paul
find out the password hasher of that app. and create a mirror of that
class of course the cakephp way. password hashers are found in
app/controller/components/auth. Optionally  your custom hashers can
extent AbstractPasswordHasher

On 6/25/15, 'Cruisine' via CakePHP cake-php@googlegroups.com wrote:
 Dear friends,

 Recently i'm working with cakephp project. The database used in the project

 is from another already built application (non-cakephp app), which is has
 its own user table that has full of user's datas. The password are already
 hashed from that application. My question is, how can i create a login user

 in my current cakephp project which can read the already-hashed password
 from that user table ?

 My question might be too basic to you, but i sincerely need your helps.

 Thank You.

 --
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/d/optout.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


How to create Login using already-hashed password from another application (non-cakephp application)

2015-06-24 Thread 'Cruisine' via CakePHP
Dear friends,

Recently i'm working with cakephp project. The database used in the project 
is from another already built application (non-cakephp app), which is has 
its own user table that has full of user's datas. The password are already 
hashed from that application. My question is, how can i create a login user 
in my current cakephp project which can read the already-hashed password 
from that user table ?

My question might be too basic to you, but i sincerely need your helps. 

Thank You.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: How to create Login using already-hashed password from another application (non-cakephp application)

2015-06-24 Thread Dr. Tarique Sani
You create a custom password hasher class

See
http://book.cakephp.org/3.0/en/controllers/components/authentication.html#creating-custom-password-hasher-classes


On Thu, Jun 25, 2015 at 9:39 AM, 'Cruisine' via CakePHP 
cake-php@googlegroups.com wrote:

 Dear friends,

 Recently i'm working with cakephp project. The database used in the
 project is from another already built application (non-cakephp app), which
 is has its own user table that has full of user's datas. The password are
 already hashed from that application. My question is, how can i create a
 login user in my current cakephp project which can read the already-hashed
 password from that user table ?

 My question might be too basic to you, but i sincerely need your helps.

 Thank You.

 --
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/d/optout.




-- 
=
Hire a CakePHP dev team : http://sanisoft.com
=

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cakephp 3.0- login and registration using custom tables

2015-06-08 Thread José Lorenzo
Read this part of the 
manual: 
http://book.cakephp.org/3.0/en/controllers/components/authentication.html#configuring-authentication-handlers

Specifically the part regarding 'userModel' and 'fields'

On Sunday, June 7, 2015 at 9:33:23 PM UTC+2, Leo Wong wrote:

 Hello,

 I have the same question, cakephp provide advance feature but require some 
 specific Talbe/Field, How can we know more detail about those name ?
 Thank you.

 On Monday, June 1, 2015 at 5:39:15 AM UTC+8, sakshi bhalla wrote:

 Hello,
  
 can anyone please help me with the source code for login and registration 
 using custom tables.
 I am able to do using users table but not able to do using my existing db 
 tables.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.4 Auth-login() always return TRUE ... ?

2015-06-07 Thread Rawal Hardik
I have same issue! Code seems almost seems.
Can anyone please help me out???plz

-- appcontroller

?php

// app/Controller/AppController.php
class AppController extends Controller {
 public $components = array(
'Session',
'Auth' = array(
'loginRedirect' = array(
'controller' = 'users',
'action' = 'index'
),
'loginAction' = array('controller' = 'users', 'action' = 
'login'),

'logoutRedirect' = array(
'controller' = 'users',
'action' = 'login',
),'authorize' = array('Controller')

)
);


public function beforeFilter() {
  $this-Auth-allow('index', 'view','login');
}
}
?

login.ctp

div class=users form
?php echo $this-Session-flash('auth'); ?
?php echo $this-Form-create('User'); ?
fieldset
legend
?php echo __('Please enter your username and password'); ?
/legend
?php echo $this-Form-input('username');
echo $this-Form-input('password');
?
/fieldset
?php echo $this-Form-end(__('Login')); ?
/div

controller

public function login() { 
 
if ($this-request-is('post')) {

 $this-Auth-authenticate['Form'] = array('fields' = array('username' 
= 'username'));
 //$this-request-data['User']['id'] = $this-User-id; 
 debug($this-request-data);
if ($this-Auth-login()) {
 $this-Session-setFlash(sprintf(Welcome %s!, 
$this-Auth-user('username')));
return $this-redirect($this-Auth-redirect());
}
$this-Session-setFlash(__('Invalid username or password, try 
again'));
}
}

help plz

On Tuesday, 15 April 2014 17:16:56 UTC+5:30, MedAL wrote:

 Hello,Iread the documentation to create a simple login form.each time I 
 try to log in it returns true  always;

 //UsersController
 public function login() { 
  if ($this-Auth-user()) {
 $this-redirect($this-Auth-redirect());
 }

 if ($this-request-is('post')) {

  $this-Auth-authenticate['Form'] = array('fields' = 
 array('username' = 'username'));
  $this-request-data['User']['id'] = $this-User-id; 
  debug($this-request-data);
 if ($this-Auth-login($this-request-data['User'])) {
  $this-Session-setFlash(sprintf(Welcome %s!, 
 $this-Auth-user('username')));
 return $this-redirect($this-Auth-redirect());
 }
 $this-Session-setFlash(__('Invalid username or password, try 
 again'));
 }
 }





 //AppController
 class AppController extends Controller {

 public $components = array(
 'Session',
 'Auth' = array(
 'loginRedirect' = array(
 'controller' = 'Events',
 'action' = 'index'
 ),
 'loginAction' = array('controller' = 'Users', 'action' = 
 'login'),

 'logoutRedirect' = array(
 'controller' = 'Users',
 'action' = 'login',
 'home'
 ),'authorize' = array('Controller')

 )
 );

 public function beforeFilter() {
 //parent::beforeFilter();
 $this-Auth-allow('index', 'view','login');
 /* $this-Auth-authenticate = array(
 'Basic' = array('userModel' = 'User'),
 'Form' = array('userModel' = 'User')
 );*/

 }



 //login.ctp


 div class=users form
 ?php echo $this-Session-flash('auth'); ?

 ?php echo $this-Form-create('User'); ?

 fieldset
 legend
 ?php echo __('Please enter your username and password'); ?
 /legend
 ?php echo $this-Form-input('username'); 
 echo $this-Form-input('password');
 ?
 /fieldset
 ?php echo $this-Form-end(__('Login')); ?
 /div


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cakephp 3.0- login and registration using custom tables

2015-06-07 Thread Leo Wong
Hello,

I have the same question, cakephp provide advance feature but require some 
specific Talbe/Field, How can we know more detail about those name ?
Thank you.

On Monday, June 1, 2015 at 5:39:15 AM UTC+8, sakshi bhalla wrote:

 Hello,
  
 can anyone please help me with the source code for login and registration 
 using custom tables.
 I am able to do using users table but not able to do using my existing db 
 tables.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Login/Registration

2015-06-01 Thread Gaurav Kumar
I think you have to read the CakePHP docs then you will definitely get all 
the answers.

On Monday, June 1, 2015 at 3:09:15 AM UTC+5:30, sakshi bhalla wrote:

 All,

 I am new to Cake PHP. I am developing a website and struggling to complete 
 the initial login/registration page.
 Not sure, how should i link between html/css pages with my controller and 
 where should i authenticate user with my database.
 Can anyone share the general structure for login/registration for web app 
 using cake php.


 Thanks
 Sakshi


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Login/Registration

2015-05-31 Thread sakshi bhalla
All,

I am new to Cake PHP. I am developing a website and struggling to complete 
the initial login/registration page.
Not sure, how should i link between html/css pages with my controller and 
where should i authenticate user with my database.
Can anyone share the general structure for login/registration for web app 
using cake php.


Thanks
Sakshi

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


cakephp 3.0- login and registration using custom tables

2015-05-31 Thread sakshi bhalla
Hello,
 
can anyone please help me with the source code for login and registration 
using custom tables.
I am able to do using users table but not able to do using my existing db 
tables.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePhp 3.0 unable to login

2015-02-25 Thread jadb
You aren't defining the custom models you are using. By default Auth 
expects Users table not Usarios. 

Read more here: 
http://book.cakephp.org/3.0/en/controllers/components/authentication.html#configuring-authentication-handlers
 

On Sunday, 22 February 2015 11:05:53 UTC-5, s.m.s...@gmail.com wrote:

 I'm new to CakePhp framework and followed the blog tutorial. Everything 
 went smooth until authentication part.

 This is my login method from UsersControllers.php, the debug line always 
 returns false.

 public function login()
 {
 if ($this-request-is('post')) {
 debug($this-Auth-identify());
 $user = $this-Auth-identify();
 if ($user) {
 $this-Auth-setUser($user);
 return $this-redirect($this-Auth-redirectUrl());
 }
 $this-Flash-error(__('Usuario o contraseña inválida, intente 
 nuevamente'));
 }
 }

 This is my user class I had to change the line protected $_accessible = 
 ['*' = true]; as appears in the tutorial, otherwise users wouldn't be 
 saved.

 class User extends Entity{
 // Make all fields mass assignable for now.
 protected $_accessible = ['username' = 
 true,'password'=true,'role'=true,'created'=true,'modified'=true];
 // ...
 protected function _setPassword($password)
 {
 return (new DefaultPasswordHasher)-hash($password);
 }
 // ...}

 This is my login.ctp

 div class=users form
 ?= $this-Flash-render('auth') ?
 ?= $this-Form-create() ?
 fieldset
 legend?= __('Ingrese su usuario y contraseña') ?/legend
 ?= $this-Form-input('Usuario') ?
 ?= $this-Form-input('Contraseña') ?
 /fieldset
 ?= $this-Form-button(__('Login')); ?
 ?= $this-Form-end() ?/div

 These are my AppController.php methods:

 public function initialize(){
 $this-loadComponent('Flash');
 $this-loadComponent('Auth', [
 'loginRedirect' = [
 'controller' = 'Expedientes',
 'action' = 'index'
 ],
 'logoutRedirect' = [
 'controller' = 'Pages',
 'action' = 'display',
 'home'
 ]
 ]);}
 public function beforeFilter(Event $event){
$this-Auth-allow(['index', 'view']);}

 At this point I can add users, their passwords are hashed but I can't 
 login. Any help will be greatly appreciated. Thanks in advance.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Manual login with Auth-login()

2015-02-25 Thread Chauncey Starkey
I am getting a successful login with Opauth, and sending results to Auth 
for login, which is returning true, yet when I continue into the protected 
area I am notified You are not authorized to access that location. and 
redirected to the login page. I'm sure I'm missing something obvious... 
Code follows, thanks for any help!

class User extends AppModel {
public $validate = array(
'provider' = array(
'rule' = 'notEmpty'
),
'uid' = array(
'rule' = 'notEmpty'
),
'name' = array(
'rule' = 'notEmpty'
),
'email' = array(
'rule' = 'notEmpty'
)
);
}

class AppController extends Controller {
public $components = array(
'Session',
'Auth' = array(
'loginRedirect' = array(
'controller' = 'pages',
'action' = 'index'
),
'logoutRedirect' = array(
'controller' = 'users',
'action' = 'login'
)
)
);
public function beforeFilter() {
$this-Auth-allow('opauth_complete', 'logout');
}
}

public function opauth_complete() {
// Find User
$user = $this-User-find('first', array(
'conditions' = array(
'provider' = $this-data['auth']['provider'],
'uid' = $this-data['auth']['uid']
)
));
 if (empty($user)) {
// Process user for access request, notify user of approval/disapproval 
when processed
}
elseif (empty($user['User']['role'])) {
// Notify user request hasn't been processed yet; don't call us, 
we'll call you
}
elseif ($user['User']['role'] == Denied) {
// Notify user they have been denied access by the administrator
}
else {
// Authorized User, Login
if ($this-Auth-login($user)) {
// Welcome user back (this is happening)
}
else {
// Notify login failed (not happening)
}
}
}

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePhp 3.0 unable to login

2015-02-24 Thread cesar calvo
Try this approach and reminds you better have the names of the tables and 
columns in English
Default is: Table users and username/password for auth fields.


public function login()
{
$user = $this-Users-newEntity();
if ($this-request-is('post')) {
$user = $this-Users-patchEntity($user, $this-request-data);
$auth = $this-Auth-identify();
if ($auth) {
$this-Auth-setUser($auth);
return $this-redirect($this-Auth-redirectUrl());
}
$this-Flash-error(__('Invalid credentials.'));
}
$this-set(compact('user'));
}




El domingo, 22 de febrero de 2015, 14:05:53 (UTC-2), s.m.s...@gmail.com 
escribió:

 I'm new to CakePhp framework and followed the blog tutorial. Everything 
 went smooth until authentication part.

 This is my login method from UsersControllers.php, the debug line always 
 returns false.

 public function login()
 {
 if ($this-request-is('post')) {
 debug($this-Auth-identify());
 $user = $this-Auth-identify();
 if ($user) {
 $this-Auth-setUser($user);
 return $this-redirect($this-Auth-redirectUrl());
 }
 $this-Flash-error(__('Usuario o contraseña inválida, intente 
 nuevamente'));
 }
 }

 This is my user class I had to change the line protected $_accessible = 
 ['*' = true]; as appears in the tutorial, otherwise users wouldn't be 
 saved.

 class User extends Entity{
 // Make all fields mass assignable for now.
 protected $_accessible = ['username' = 
 true,'password'=true,'role'=true,'created'=true,'modified'=true];
 // ...
 protected function _setPassword($password)
 {
 return (new DefaultPasswordHasher)-hash($password);
 }
 // ...}

 This is my login.ctp

 div class=users form
 ?= $this-Flash-render('auth') ?
 ?= $this-Form-create() ?
 fieldset
 legend?= __('Ingrese su usuario y contraseña') ?/legend
 ?= $this-Form-input('Usuario') ?
 ?= $this-Form-input('Contraseña') ?
 /fieldset
 ?= $this-Form-button(__('Login')); ?
 ?= $this-Form-end() ?/div

 These are my AppController.php methods:

 public function initialize(){
 $this-loadComponent('Flash');
 $this-loadComponent('Auth', [
 'loginRedirect' = [
 'controller' = 'Expedientes',
 'action' = 'index'
 ],
 'logoutRedirect' = [
 'controller' = 'Pages',
 'action' = 'display',
 'home'
 ]
 ]);}
 public function beforeFilter(Event $event){
$this-Auth-allow(['index', 'view']);}

 At this point I can add users, their passwords are hashed but I can't 
 login. Any help will be greatly appreciated. Thanks in advance.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


CakePhp 3.0 unable to login

2015-02-23 Thread s . m . scarano


I'm new to CakePhp framework and followed the blog tutorial. Everything 
went smooth until authentication part.

This is my login method from UsersControllers.php, the debug line always 
returns false.

public function login()
{
if ($this-request-is('post')) {
debug($this-Auth-identify());
$user = $this-Auth-identify();
if ($user) {
$this-Auth-setUser($user);
return $this-redirect($this-Auth-redirectUrl());
}
$this-Flash-error(__('Usuario o contraseña inválida, intente 
nuevamente'));
}
}

This is my user class I had to change the line protected $_accessible = 
['*' = true]; as appears in the tutorial, otherwise users wouldn't be 
saved.

class User extends Entity{
// Make all fields mass assignable for now.
protected $_accessible = ['username' = 
true,'password'=true,'role'=true,'created'=true,'modified'=true];
// ...
protected function _setPassword($password)
{
return (new DefaultPasswordHasher)-hash($password);
}
// ...}

This is my login.ctp

div class=users form
?= $this-Flash-render('auth') ?
?= $this-Form-create() ?
fieldset
legend?= __('Ingrese su usuario y contraseña') ?/legend
?= $this-Form-input('Usuario') ?
?= $this-Form-input('Contraseña') ?
/fieldset
?= $this-Form-button(__('Login')); ?
?= $this-Form-end() ?/div

These are my AppController.php methods:

public function initialize(){
$this-loadComponent('Flash');
$this-loadComponent('Auth', [
'loginRedirect' = [
'controller' = 'Expedientes',
'action' = 'index'
],
'logoutRedirect' = [
'controller' = 'Pages',
'action' = 'display',
'home'
]
]);}
public function beforeFilter(Event $event){
   $this-Auth-allow(['index', 'view']);}

At this point I can add users, their passwords are hashed but I can't 
login. Any help will be greatly appreciated. Thanks in advance.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-02-14 Thread tech_me
I got it worked!

But not only the problem of table fields(even though `password` field is 
required with hashed value).

The main problem is the html file.

Let me say, I have input elements which their values of `name` attribute 
are `email` and `password`.
But I have tried half a day to look over through the ctp way from source 
code those generated at runtime, in which are `data[User][email]` and 
`data[User][password]`.

So, I change my attribute values in the html file to the `data[User][]` 
format, works like a charm \^o^/

Thanks for you all help.
Best regards, tech_me.


On Thursday, February 12, 2015 at 5:27:00 AM UTC+9, John Andersen wrote:

 Ah, I see your problem :)

 Please ensure that your users table has at least these columns:
 id, username, password

 The id column is just the primary key for the table and CakePHP uses the 
 id to identify records in the table.

 Auth will use the username and password columns to identify the user who 
 logs in.

 Yes, password should be 40 characters long when using that password hasher.

 Please correct your users table and see if it now solves your issue. 
 Please also inform back here so other having the same issue may know.

 Thanks and enjoy, John


 On Wednesday, 11 February 2015 10:06:16 UTC+2, tech_me wrote:

 Hi John,

 Sorry for replying late.
 I have been very busing recently and have less time to continue on this 
 issue.

 Today I make some time to try your solution, got a good result and a bad 
 one:
 - GOOD
 `passwordHasher`, yes, it worked.
 It saved hashed password(123) against id(1001) to my table, which is 
 **f034a6b0709eb2b2bd1b2eb47987ab6e334ca7a6**(40 chars?!)

 - BAD
 Nothing changed, `$this-Auth-login()` still returning `false`. 


 ADDITIONAL
 I have two input elements in my html(with PHPTAL), theirs `name` 
 attributes are `username` and `password`,
 while there are `id` and 'password' fields in my table.
 So
 `
 ...
 'authenticate' = array(
 'Form' = array('userModel' = 'User',
 'fields' = array('username' = 'id',
 'password' = 'password'))),
 ...
 `
 is there anything incorrect?

 Thank you, tech_me

 [snip]



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-02-11 Thread John Andersen
Ah, I see your problem :)

Please ensure that your users table has at least these columns:
id, username, password

The id column is just the primary key for the table and CakePHP uses the id 
to identify records in the table.

Auth will use the username and password columns to identify the user who 
logs in.

Yes, password should be 40 characters long when using that password hasher.

Please correct your users table and see if it now solves your issue. Please 
also inform back here so other having the same issue may know.

Thanks and enjoy, John


On Wednesday, 11 February 2015 10:06:16 UTC+2, tech_me wrote:

 Hi John,

 Sorry for replying late.
 I have been very busing recently and have less time to continue on this 
 issue.

 Today I make some time to try your solution, got a good result and a bad 
 one:
 - GOOD
 `passwordHasher`, yes, it worked.
 It saved hashed password(123) against id(1001) to my table, which is 
 **f034a6b0709eb2b2bd1b2eb47987ab6e334ca7a6**(40 chars?!)

 - BAD
 Nothing changed, `$this-Auth-login()` still returning `false`. 


 ADDITIONAL
 I have two input elements in my html(with PHPTAL), theirs `name` 
 attributes are `username` and `password`,
 while there are `id` and 'password' fields in my table.
 So
 `
 ...
 'authenticate' = array(
 'Form' = array('userModel' = 'User',
 'fields' = array('username' = 'id',
 'password' = 'password'))),
 ...
 `
 is there anything incorrect?

 Thank you, tech_me

 [snip]


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-02-11 Thread tech_me
Hi John,

Sorry for replying late.
I have been very busing recently and have less time to continue on this 
issue.

Today I make some time to try your solution, got a good result and a bad 
one:
- GOOD
`passwordHasher`, yes, it worked.
It saved hashed password(123) against id(1001) to my table, which is 
**f034a6b0709eb2b2bd1b2eb47987ab6e334ca7a6**(40 chars?!)

- BAD
Nothing changed, `$this-Auth-login()` still returning `false`. 


ADDITIONAL
I have two input elements in my html(with PHPTAL), theirs `name` attributes 
are `username` and `password`,
while there are `id` and 'password' fields in my table.
So
`
...
'authenticate' = array(
'Form' = array('userModel' = 'User',
'fields' = array('username' = 'id',
'password' = 'password'))),
...
`
is there anything incorrect?

Thank you, tech_me


On Friday, January 16, 2015 at 2:48:09 AM UTC+9, John Andersen wrote:

 You have a users table with two records, where the one with id = 1001 has 
 the password = 123. The password needs to be changed to the hashed value 
 that Auth/password hasher can provide to you.

 Make sure that your password column in the table has a definition that can 
 contain a hashed password - think it should be 32 character (please correct 
 me if I am wrong).

 As a temporary solution (other may provide a better one :)

 In you controller, at the beginning of the login method, add this:
 // Make user 1001 the current in the User model
 $this-User-id = 1001;

 // Activate the simple password hasher and hash the password '123'.

 $passwordHasher = new SimplePasswordHasher();
 $pw1001 = $passwordHasher-hash('123');


 // Save the password to the hashed value of 123 for the current user 1001
 $this-User-saveField('password', $pw1001);

 Then try to login only once and check your database to see whether or not 
 the password has changed value to something

 If the password in the table has changed, then comment out the above code 
 and try to login again using password 123.

 Enjoy, John


 On Thursday, 15 January 2015 16:37:37 UTC+2, tech_me wrote:

 Hi John,

  Use the password hasher to hash your password, then save it instead of 
 123 and it should work.
 So could I put hasshed password to table without create new user record?
 I have read your link, but there is just creating user...

 Besides users, lots of tests are able to be tested just by searching but 
 not creating new record for those purposes.

 Thanks, tech_me 


 On Thursday, January 15, 2015 at 5:15:16 AM UTC+9, John Andersen wrote:

 Use the password hasher to hash your password, then save it instead of 
 123 and it should work.

 See the CakePHP book at this location for the password hasher:

 http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#hashing-passwords

 Enjoy, John

 On Sunday, 11 January 2015 13:52:07 UTC+2, tech_me wrote:

  If '123' is the actual data in your password field in the data 
 record, it's very likely this is the problem you're having with logging in.
 Maybe this is the problem;)

 [snip]



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


How to create a multiple of login with Tables Different ? #5729

2015-01-25 Thread Lucas Macedo


I'm trying to create a login system with using two different tables one for 
the board administrator othe apar customer and am having a problem because 
both logins use by default the Users table and I'm unable to change ..
If they can deem a look at my code

https://github.com/luuckx2/cakephp3-MultipleAuth/blob/master/src/Controller/AppController.php

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-01-15 Thread John Andersen
You have a users table with two records, where the one with id = 1001 has 
the password = 123. The password needs to be changed to the hashed value 
that Auth/password hasher can provide to you.

Make sure that your password column in the table has a definition that can 
contain a hashed password - think it should be 32 character (please correct 
me if I am wrong).

As a temporary solution (other may provide a better one :)

In you controller, at the beginning of the login method, add this:
// Make user 1001 the current in the User model
$this-User-id = 1001;

// Activate the simple password hasher and hash the password '123'.

$passwordHasher = new SimplePasswordHasher();
$pw1001 = $passwordHasher-hash('123');


// Save the password to the hashed value of 123 for the current user 1001
$this-User-saveField('password', $pw1001);

Then try to login only once and check your database to see whether or not 
the password has changed value to something

If the password in the table has changed, then comment out the above code 
and try to login again using password 123.

Enjoy, John


On Thursday, 15 January 2015 16:37:37 UTC+2, tech_me wrote:

 Hi John,

  Use the password hasher to hash your password, then save it instead of 
 123 and it should work.
 So could I put hasshed password to table without create new user record?
 I have read your link, but there is just creating user...

 Besides users, lots of tests are able to be tested just by searching but 
 not creating new record for those purposes.

 Thanks, tech_me 


 On Thursday, January 15, 2015 at 5:15:16 AM UTC+9, John Andersen wrote:

 Use the password hasher to hash your password, then save it instead of 
 123 and it should work.

 See the CakePHP book at this location for the password hasher:

 http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#hashing-passwords

 Enjoy, John

 On Sunday, 11 January 2015 13:52:07 UTC+2, tech_me wrote:

  If '123' is the actual data in your password field in the data record, 
 it's very likely this is the problem you're having with logging in.
 Maybe this is the problem;)

 [snip]



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-01-15 Thread tech_me
Hi John,

 Use the password hasher to hash your password, then save it instead of 
123 and it should work.
So could I put hasshed password to table without create new user record?
I have read your link, but there is just creating user...

Besides users, lots of tests are able to be tested just by searching but 
not creating new record for those purposes.

Thanks, tech_me 


On Thursday, January 15, 2015 at 5:15:16 AM UTC+9, John Andersen wrote:

 Use the password hasher to hash your password, then save it instead of 
 123 and it should work.

 See the CakePHP book at this location for the password hasher:

 http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#hashing-passwords

 Enjoy, John

 On Sunday, 11 January 2015 13:52:07 UTC+2, tech_me wrote:

  If '123' is the actual data in your password field in the data record, 
 it's very likely this is the problem you're having with logging in.
 Maybe this is the problem;)

 [snip]



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-01-14 Thread John Andersen
Use the password hasher to hash your password, then save it instead of 
123 and it should work.

See the CakePHP book at this location for the password hasher:
http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#hashing-passwords

Enjoy, John

On Sunday, 11 January 2015 13:52:07 UTC+2, tech_me wrote:

  If '123' is the actual data in your password field in the data record, 
 it's very likely this is the problem you're having with logging in.
 Maybe this is the problem;)

 [snip]


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-01-13 Thread Joe T.
i'm not sure if/how you can disable Auth's automatic hashing of the 
password value to authenticate the login. In any case, i'd be very careful 
about doing so. i have a very basic understanding of that component. 

Someone else would have to speak to that, and any ideas for converting the 
existing user record's password without setting up a new account. i don't 
know if there are that many options. Security sacrifices a good amount of 
flexibility in cases like this.

-joe


On Sunday, 11 January 2015 06:52:07 UTC-5, tech_me wrote:

  If '123' is the actual data in your password field in the data record, 
 it's very likely this is the problem you're having with logging in.
 Maybe this is the problem;)

  That's why i recommended setting up the create-user form from the 
 tutorial. 
  It will set up the creation of the user record, which will encrypt the 
 password you supply and store *that* version in the table for comparison 
 during login.
 I will try the CTP style login soon.
 But, could I use existed (user) data if I just wanted to test my login 
 success or failure with session functionality?
 Not want to do the creating user process before other implementations.

 Thank you,
 tech_me


 On Tuesday, January 6, 2015 at 9:11:07 AM UTC+9, Joe T. wrote:

  Is that the actual data in `users`, or just simplified for example? 
 Just want to clarify. Manually adding records won't work in this case. 
 It is the actual data which is storing in my `users` table.

 If '123' is the actual data in your password field in the data record, 
 it's very likely this is the problem you're having with logging in.

 The line
   if ($this-Auth-login()) { ...
 fails because Auth-login() method encrypts the POST password, turning '
 *123*' into something like *$2y$10$VgMbmaJ5l96WJYJeU*... (in other 
 words, an encrypted version of '*123*'). The encrypted string is 
 compared to the database value more or less *as-is*. It expects the 
 database value to *already* be encrypted. If they match, login passes. 
 In your case:

 Encrypted POST password *$2y$10$VgMbmaJ5l96WJYJeU*... *!==* stored 
 password value *123*, so login fails.

 That's why i recommended setting up the create-user form from the 
 tutorial. It will set up the creation of the user record, which will 
 encrypt the password you supply and store *that* version in the table 
 for comparison during login.

 When i said you should adapt it to your needs, i meant the way the 
 tutorial demonstrates the Form builder for CTP may not match exactly what 
 you need for TAL. i'm unfamiliar with that, so if ignore that part if it 
 was more confusing. :)

 Hope that clears things up a *little*. :)
 -joe


 On Sunday, 4 January 2015 01:59:27 UTC-5, tech_me wrote:

 Hi Joe, 
 Happy New Year!

 I'm sorry for delaying reply you.
  Is that the actual data in `users`, or just simplified for example? 
 Just want to clarify. Manually adding records won't work in this case. 
 It is the actual data which is storing in my `users` table.

  Auth automatically encrypts the submitted password  compares it to 
 the database value. If you enter '123' as the password, it's not going to 
 match '123' in the database after Auth encrypts it.
 I don't know this issue, but entered the password `123` just as it have 
 been stored in my table.
 Maybe this is the problem...I'll check it.

  Obviously, adapt the CTP form to your TAL needs.
 What this means? Are you talking about the usage in my controller but 
 not html(TAL) files for login?

 Regards,
 tech_me


 On Tuesday, December 23, 2014 11:35:40 PM UTC+9, Joe T. wrote:

 Is that the actual data in `users`, or just simplified for example? 
 Just want to clarify. Manually adding records won't work in this case. 
 Auth 
 automatically encrypts the submitted password  compares it to the 
 database 
 value. If you enter '123' as the password, it's not going to match '123' 
 in 
 the database after Auth encrypts it.

 Look here for how to set up adding/editing users: 
 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
 Obviously, adapt the CTP form to your TAL needs.

 Hope that helps...
 -joe t.


 On Monday, 22 December 2014 20:42:33 UTC-5, tech_me wrote:

 By the way, I have a table `users` in my db, which have 2 records.
 id,   email,  password
 1001, abc@com, 123
 1002, abc@org, 456

 When I input email and password on the login form, it fails at `if 
 ($this-Auth-login())`


 On Tuesday, December 23, 2014 10:39:39 AM UTC+9, tech_me wrote:

 In my view file(html)
 form method=POST tal:attributes=action string:/users/login
 input type=text name=email size=15 maxlength=30 
 placeholder=your email /br /
 input type=password name=password size=15 maxlength=15 
 placeholder=password /br /
 input type=submit value=login /
 /form

 In my AppController.php
 public $components = array('RequestHandler',
 'Auth' = array(
 'authenticate' = array

Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-01-11 Thread tech_me
 If '123' is the actual data in your password field in the data record, 
it's very likely this is the problem you're having with logging in.
Maybe this is the problem;)

 That's why i recommended setting up the create-user form from the 
tutorial. 
 It will set up the creation of the user record, which will encrypt the 
password you supply and store *that* version in the table for comparison 
during login.
I will try the CTP style login soon.
But, could I use existed (user) data if I just wanted to test my login 
success or failure with session functionality?
Not want to do the creating user process before other implementations.

Thank you,
tech_me


On Tuesday, January 6, 2015 at 9:11:07 AM UTC+9, Joe T. wrote:

  Is that the actual data in `users`, or just simplified for example? 
 Just want to clarify. Manually adding records won't work in this case. 
 It is the actual data which is storing in my `users` table.

 If '123' is the actual data in your password field in the data record, 
 it's very likely this is the problem you're having with logging in.

 The line
   if ($this-Auth-login()) { ...
 fails because Auth-login() method encrypts the POST password, turning '
 *123*' into something like *$2y$10$VgMbmaJ5l96WJYJeU*... (in other words, 
 an encrypted version of '*123*'). The encrypted string is compared to the 
 database value more or less *as-is*. It expects the database value to 
 *already* be encrypted. If they match, login passes. In your case:

 Encrypted POST password *$2y$10$VgMbmaJ5l96WJYJeU*... *!==* stored 
 password value *123*, so login fails.

 That's why i recommended setting up the create-user form from the 
 tutorial. It will set up the creation of the user record, which will 
 encrypt the password you supply and store *that* version in the table for 
 comparison during login.

 When i said you should adapt it to your needs, i meant the way the 
 tutorial demonstrates the Form builder for CTP may not match exactly what 
 you need for TAL. i'm unfamiliar with that, so if ignore that part if it 
 was more confusing. :)

 Hope that clears things up a *little*. :)
 -joe


 On Sunday, 4 January 2015 01:59:27 UTC-5, tech_me wrote:

 Hi Joe, 
 Happy New Year!

 I'm sorry for delaying reply you.
  Is that the actual data in `users`, or just simplified for example? 
 Just want to clarify. Manually adding records won't work in this case. 
 It is the actual data which is storing in my `users` table.

  Auth automatically encrypts the submitted password  compares it to the 
 database value. If you enter '123' as the password, it's not going to match 
 '123' in the database after Auth encrypts it.
 I don't know this issue, but entered the password `123` just as it have 
 been stored in my table.
 Maybe this is the problem...I'll check it.

  Obviously, adapt the CTP form to your TAL needs.
 What this means? Are you talking about the usage in my controller but not 
 html(TAL) files for login?

 Regards,
 tech_me


 On Tuesday, December 23, 2014 11:35:40 PM UTC+9, Joe T. wrote:

 Is that the actual data in `users`, or just simplified for example? Just 
 want to clarify. Manually adding records won't work in this case. Auth 
 automatically encrypts the submitted password  compares it to the database 
 value. If you enter '123' as the password, it's not going to match '123' in 
 the database after Auth encrypts it.

 Look here for how to set up adding/editing users: 
 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
 Obviously, adapt the CTP form to your TAL needs.

 Hope that helps...
 -joe t.


 On Monday, 22 December 2014 20:42:33 UTC-5, tech_me wrote:

 By the way, I have a table `users` in my db, which have 2 records.
 id,   email,  password
 1001, abc@com, 123
 1002, abc@org, 456

 When I input email and password on the login form, it fails at `if 
 ($this-Auth-login())`


 On Tuesday, December 23, 2014 10:39:39 AM UTC+9, tech_me wrote:

 In my view file(html)
 form method=POST tal:attributes=action string:/users/login
 input type=text name=email size=15 maxlength=30 
 placeholder=your email /br /
 input type=password name=password size=15 maxlength=15 
 placeholder=password /br /
 input type=submit value=login /
 /form

 In my AppController.php
 public $components = array('RequestHandler',
 'Auth' = array(
 'authenticate' = array(
 'Form' = array('userModel' = 'User',
 'fields' = array('username' = 
 'email',
 'password' = 
 'password'))),
 'loginAction' = array('controller' = 'users', 
 'action' = 'login'));

 public function beforeFilter() {
 $this-Auth-allow('login', 'logout');
 }

 In my UsersController.php
 public function login() {
 if ($this-request-is('post')) {
if ($this-Auth-login()) {
 return $this-redirect

Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-01-05 Thread Joe T.
 Is that the actual data in `users`, or just simplified for example? Just 
want to clarify. Manually adding records won't work in this case. 
It is the actual data which is storing in my `users` table.

If '123' is the actual data in your password field in the data record, it's 
very likely this is the problem you're having with logging in.

The line
  if ($this-Auth-login()) { ...
fails because Auth-login() method encrypts the POST password, turning '
*123*' into something like *$2y$10$VgMbmaJ5l96WJYJeU*... (in other words, 
an encrypted version of '*123*'). The encrypted string is compared to the 
database value more or less *as-is*. It expects the database value to 
*already* be encrypted. If they match, login passes. In your case:

Encrypted POST password *$2y$10$VgMbmaJ5l96WJYJeU*... *!==* stored password 
value *123*, so login fails.

That's why i recommended setting up the create-user form from the tutorial. 
It will set up the creation of the user record, which will encrypt the 
password you supply and store *that* version in the table for comparison 
during login.

When i said you should adapt it to your needs, i meant the way the tutorial 
demonstrates the Form builder for CTP may not match exactly what you need 
for TAL. i'm unfamiliar with that, so if ignore that part if it was more 
confusing. :)

Hope that clears things up a *little*. :)
-joe


On Sunday, 4 January 2015 01:59:27 UTC-5, tech_me wrote:

 Hi Joe, 
 Happy New Year!

 I'm sorry for delaying reply you.
  Is that the actual data in `users`, or just simplified for example? Just 
 want to clarify. Manually adding records won't work in this case. 
 It is the actual data which is storing in my `users` table.

  Auth automatically encrypts the submitted password  compares it to the 
 database value. If you enter '123' as the password, it's not going to match 
 '123' in the database after Auth encrypts it.
 I don't know this issue, but entered the password `123` just as it have 
 been stored in my table.
 Maybe this is the problem...I'll check it.

  Obviously, adapt the CTP form to your TAL needs.
 What this means? Are you talking about the usage in my controller but not 
 html(TAL) files for login?

 Regards,
 tech_me


 On Tuesday, December 23, 2014 11:35:40 PM UTC+9, Joe T. wrote:

 Is that the actual data in `users`, or just simplified for example? Just 
 want to clarify. Manually adding records won't work in this case. Auth 
 automatically encrypts the submitted password  compares it to the database 
 value. If you enter '123' as the password, it's not going to match '123' in 
 the database after Auth encrypts it.

 Look here for how to set up adding/editing users: 
 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
 Obviously, adapt the CTP form to your TAL needs.

 Hope that helps...
 -joe t.


 On Monday, 22 December 2014 20:42:33 UTC-5, tech_me wrote:

 By the way, I have a table `users` in my db, which have 2 records.
 id,   email,  password
 1001, abc@com, 123
 1002, abc@org, 456

 When I input email and password on the login form, it fails at `if 
 ($this-Auth-login())`


 On Tuesday, December 23, 2014 10:39:39 AM UTC+9, tech_me wrote:

 In my view file(html)
 form method=POST tal:attributes=action string:/users/login
 input type=text name=email size=15 maxlength=30 
 placeholder=your email /br /
 input type=password name=password size=15 maxlength=15 
 placeholder=password /br /
 input type=submit value=login /
 /form

 In my AppController.php
 public $components = array('RequestHandler',
 'Auth' = array(
 'authenticate' = array(
 'Form' = array('userModel' = 'User',
 'fields' = array('username' = 
 'email',
 'password' = 'password'))),
 'loginAction' = array('controller' = 'users', 
 'action' = 'login'));

 public function beforeFilter() {
 $this-Auth-allow('login', 'logout');
 }

 In my UsersController.php
 public function login() {
 if ($this-request-is('post')) {
if ($this-Auth-login()) {
 return $this-redirect($this-Auth-redirect());
 } else {
 echo ('failed'); // Always come here...
 }
 }
 }

 public function logout() {
 $this-Auth-logout();
 $this-Session-destroy();
 $this-redirect(array('action' = 'login'));
 }

 Could you give some hints, please?
 Thank you.


 On Sunday, December 21, 2014 4:48:14 PM UTC+9, tech_me wrote:

 1. Yes
 2. Yes
 3. No any error but just failed(false) at that `if` statement.
 4. Maybe there is no the same name field in my user table, which is 
 'email' in html while 'nickname' in table schema

 I will have a try soon.
 Thank you.


 On Friday, December 19, 2014 4:55:03 AM UTC+9, John Andersen wrote:

 Please provide more

Re: CakePHP 2.0 authentication(login) without ctp files but other types

2015-01-03 Thread tech_me
Hi Joe, 
Happy New Year!

I'm sorry for delaying reply you.
 Is that the actual data in `users`, or just simplified for example? Just 
want to clarify. Manually adding records won't work in this case. 
It is the actual data which is storing in my `users` table.

 Auth automatically encrypts the submitted password  compares it to the 
database value. If you enter '123' as the password, it's not going to match 
'123' in the database after Auth encrypts it.
I don't know this issue, but entered the password `123` just as it have 
been stored in my table.
Maybe this is the problem...I'll check it.

 Obviously, adapt the CTP form to your TAL needs.
What this means? Are you talking about the usage in my controller but not 
html(TAL) files for login?

Regards,
tech_me


On Tuesday, December 23, 2014 11:35:40 PM UTC+9, Joe T. wrote:

 Is that the actual data in `users`, or just simplified for example? Just 
 want to clarify. Manually adding records won't work in this case. Auth 
 automatically encrypts the submitted password  compares it to the database 
 value. If you enter '123' as the password, it's not going to match '123' in 
 the database after Auth encrypts it.

 Look here for how to set up adding/editing users: 
 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
 Obviously, adapt the CTP form to your TAL needs.

 Hope that helps...
 -joe t.


 On Monday, 22 December 2014 20:42:33 UTC-5, tech_me wrote:

 By the way, I have a table `users` in my db, which have 2 records.
 id,   email,  password
 1001, abc@com, 123
 1002, abc@org, 456

 When I input email and password on the login form, it fails at `if 
 ($this-Auth-login())`


 On Tuesday, December 23, 2014 10:39:39 AM UTC+9, tech_me wrote:

 In my view file(html)
 form method=POST tal:attributes=action string:/users/login
 input type=text name=email size=15 maxlength=30 placeholder
 =your email /br /
 input type=password name=password size=15 maxlength=15 
 placeholder=password /br /
 input type=submit value=login /
 /form

 In my AppController.php
 public $components = array('RequestHandler',
 'Auth' = array(
 'authenticate' = array(
 'Form' = array('userModel' = 'User',
 'fields' = array('username' = 
 'email',
 'password' = 'password'))),
 'loginAction' = array('controller' = 'users', 
 'action' = 'login'));

 public function beforeFilter() {
 $this-Auth-allow('login', 'logout');
 }

 In my UsersController.php
 public function login() {
 if ($this-request-is('post')) {
if ($this-Auth-login()) {
 return $this-redirect($this-Auth-redirect());
 } else {
 echo ('failed'); // Always come here...
 }
 }
 }

 public function logout() {
 $this-Auth-logout();
 $this-Session-destroy();
 $this-redirect(array('action' = 'login'));
 }

 Could you give some hints, please?
 Thank you.


 On Sunday, December 21, 2014 4:48:14 PM UTC+9, tech_me wrote:

 1. Yes
 2. Yes
 3. No any error but just failed(false) at that `if` statement.
 4. Maybe there is no the same name field in my user table, which is 
 'email' in html while 'nickname' in table schema

 I will have a try soon.
 Thank you.


 On Friday, December 19, 2014 4:55:03 AM UTC+9, John Andersen wrote:

 Please provide more information on the steps leading up to the error 
 that you get.
 1. Is the login form showing?
 2. Can you submit the form?
 3. Do you get the error back from your login method - wrong e-mail or 
 password?
 4. Something else?

 Suggest that you at least create the users table and add one user, so 
 that CakePHP has something to work with.

 Enjoy, John

 On Wednesday, 17 December 2014 14:14:43 UTC+2, tech_me wrote:

 I posted to SO several days ago, but no expected replies.
 http://stackoverflow.com/q/27403391

 I am now using PHPTAL http://phptal.org/ which use html instead of 
 ctp files.
 Is there anyone who use the html files to cooperate with Cake's 
 authentication?

 Thanks.




-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2014-12-23 Thread Joe T.
Is that the actual data in `users`, or just simplified for example? Just 
want to clarify. Manually adding records won't work in this case. Auth 
automatically encrypts the submitted password  compares it to the database 
value. If you enter '123' as the password, it's not going to match '123' in 
the database after Auth encrypts it.

Look here for how to set up adding/editing users: 
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
Obviously, adapt the CTP form to your TAL needs.

Hope that helps...
-joe t.


On Monday, 22 December 2014 20:42:33 UTC-5, tech_me wrote:

 By the way, I have a table `users` in my db, which have 2 records.
 id,   email,  password
 1001, abc@com, 123
 1002, abc@org, 456

 When I input email and password on the login form, it fails at `if 
 ($this-Auth-login())`


 On Tuesday, December 23, 2014 10:39:39 AM UTC+9, tech_me wrote:

 In my view file(html)
 form method=POST tal:attributes=action string:/users/login
 input type=text name=email size=15 maxlength=30 
 placeholder=your 
 email /br /
 input type=password name=password size=15 maxlength=15 
 placeholder=password /br /
 input type=submit value=login /
 /form

 In my AppController.php
 public $components = array('RequestHandler',
 'Auth' = array(
 'authenticate' = array(
 'Form' = array('userModel' = 'User',
 'fields' = array('username' = 
 'email',
 'password' = 'password'))),
 'loginAction' = array('controller' = 'users', 
 'action' = 'login'));

 public function beforeFilter() {
 $this-Auth-allow('login', 'logout');
 }

 In my UsersController.php
 public function login() {
 if ($this-request-is('post')) {
if ($this-Auth-login()) {
 return $this-redirect($this-Auth-redirect());
 } else {
 echo ('failed'); // Always come here...
 }
 }
 }

 public function logout() {
 $this-Auth-logout();
 $this-Session-destroy();
 $this-redirect(array('action' = 'login'));
 }

 Could you give some hints, please?
 Thank you.


 On Sunday, December 21, 2014 4:48:14 PM UTC+9, tech_me wrote:

 1. Yes
 2. Yes
 3. No any error but just failed(false) at that `if` statement.
 4. Maybe there is no the same name field in my user table, which is 
 'email' in html while 'nickname' in table schema

 I will have a try soon.
 Thank you.


 On Friday, December 19, 2014 4:55:03 AM UTC+9, John Andersen wrote:

 Please provide more information on the steps leading up to the error 
 that you get.
 1. Is the login form showing?
 2. Can you submit the form?
 3. Do you get the error back from your login method - wrong e-mail or 
 password?
 4. Something else?

 Suggest that you at least create the users table and add one user, so 
 that CakePHP has something to work with.

 Enjoy, John

 On Wednesday, 17 December 2014 14:14:43 UTC+2, tech_me wrote:

 I posted to SO several days ago, but no expected replies.
 http://stackoverflow.com/q/27403391

 I am now using PHPTAL http://phptal.org/ which use html instead of 
 ctp files.
 Is there anyone who use the html files to cooperate with Cake's 
 authentication?

 Thanks.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2014-12-22 Thread tech_me
In my view file(html)
form method=POST tal:attributes=action string:/users/login
input type=text name=email size=15 maxlength=30 placeholder=your 
email /br /
input type=password name=password size=15 maxlength=15 
placeholder=password /br /
input type=submit value=login /
/form

In my AppController.php
public $components = array('RequestHandler',
'Auth' = array(
'authenticate' = array(
'Form' = array('userModel' = 'User',
'fields' = array('username' = 'email',
'password' = 'password'))),
'loginAction' = array('controller' = 'users', 
'action' = 'login'));

public function beforeFilter() {
$this-Auth-allow('login', 'logout');
}

In my UsersController.php
public function login() {
if ($this-request-is('post')) {
   if ($this-Auth-login()) {
return $this-redirect($this-Auth-redirect());
} else {
echo ('failed'); // Always come here...
}
}
}

public function logout() {
$this-Auth-logout();
$this-Session-destroy();
$this-redirect(array('action' = 'login'));
}

Could you give some hints, please?
Thank you.


On Sunday, December 21, 2014 4:48:14 PM UTC+9, tech_me wrote:

 1. Yes
 2. Yes
 3. No any error but just failed(false) at that `if` statement.
 4. Maybe there is no the same name field in my user table, which is 
 'email' in html while 'nickname' in table schema

 I will have a try soon.
 Thank you.


 On Friday, December 19, 2014 4:55:03 AM UTC+9, John Andersen wrote:

 Please provide more information on the steps leading up to the error that 
 you get.
 1. Is the login form showing?
 2. Can you submit the form?
 3. Do you get the error back from your login method - wrong e-mail or 
 password?
 4. Something else?

 Suggest that you at least create the users table and add one user, so 
 that CakePHP has something to work with.

 Enjoy, John

 On Wednesday, 17 December 2014 14:14:43 UTC+2, tech_me wrote:

 I posted to SO several days ago, but no expected replies.
 http://stackoverflow.com/q/27403391

 I am now using PHPTAL http://phptal.org/ which use html instead of 
 ctp files.
 Is there anyone who use the html files to cooperate with Cake's 
 authentication?

 Thanks.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2014-12-22 Thread tech_me
By the way, I have a table `users` in my db, which have 2 records.
id,   email,  password
1001, abc@com, 123
1002, abc@org, 456

When I input email and password on the login form, it fails at `if 
($this-Auth-login())`


On Tuesday, December 23, 2014 10:39:39 AM UTC+9, tech_me wrote:

 In my view file(html)
 form method=POST tal:attributes=action string:/users/login
 input type=text name=email size=15 maxlength=30 
 placeholder=your 
 email /br /
 input type=password name=password size=15 maxlength=15 
 placeholder=password /br /
 input type=submit value=login /
 /form

 In my AppController.php
 public $components = array('RequestHandler',
 'Auth' = array(
 'authenticate' = array(
 'Form' = array('userModel' = 'User',
 'fields' = array('username' = 
 'email',
 'password' = 'password'))),
 'loginAction' = array('controller' = 'users', 
 'action' = 'login'));

 public function beforeFilter() {
 $this-Auth-allow('login', 'logout');
 }

 In my UsersController.php
 public function login() {
 if ($this-request-is('post')) {
if ($this-Auth-login()) {
 return $this-redirect($this-Auth-redirect());
 } else {
 echo ('failed'); // Always come here...
 }
 }
 }

 public function logout() {
 $this-Auth-logout();
 $this-Session-destroy();
 $this-redirect(array('action' = 'login'));
 }

 Could you give some hints, please?
 Thank you.


 On Sunday, December 21, 2014 4:48:14 PM UTC+9, tech_me wrote:

 1. Yes
 2. Yes
 3. No any error but just failed(false) at that `if` statement.
 4. Maybe there is no the same name field in my user table, which is 
 'email' in html while 'nickname' in table schema

 I will have a try soon.
 Thank you.


 On Friday, December 19, 2014 4:55:03 AM UTC+9, John Andersen wrote:

 Please provide more information on the steps leading up to the error 
 that you get.
 1. Is the login form showing?
 2. Can you submit the form?
 3. Do you get the error back from your login method - wrong e-mail or 
 password?
 4. Something else?

 Suggest that you at least create the users table and add one user, so 
 that CakePHP has something to work with.

 Enjoy, John

 On Wednesday, 17 December 2014 14:14:43 UTC+2, tech_me wrote:

 I posted to SO several days ago, but no expected replies.
 http://stackoverflow.com/q/27403391

 I am now using PHPTAL http://phptal.org/ which use html instead of 
 ctp files.
 Is there anyone who use the html files to cooperate with Cake's 
 authentication?

 Thanks.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2014-12-20 Thread tech_me
1. Yes
2. Yes
3. No any error but just failed(false) at that `if` statement.
4. Maybe there is no the same name field in my user table, which is 'email' 
in html while 'nickname' in table schema

I will have a try soon.
Thank you.


On Friday, December 19, 2014 4:55:03 AM UTC+9, John Andersen wrote:

 Please provide more information on the steps leading up to the error that 
 you get.
 1. Is the login form showing?
 2. Can you submit the form?
 3. Do you get the error back from your login method - wrong e-mail or 
 password?
 4. Something else?

 Suggest that you at least create the users table and add one user, so that 
 CakePHP has something to work with.

 Enjoy, John

 On Wednesday, 17 December 2014 14:14:43 UTC+2, tech_me wrote:

 I posted to SO several days ago, but no expected replies.
 http://stackoverflow.com/q/27403391

 I am now using PHPTAL http://phptal.org/ which use html instead of ctp 
 files.
 Is there anyone who use the html files to cooperate with Cake's 
 authentication?

 Thanks.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.0 authentication(login) without ctp files but other types

2014-12-18 Thread John Andersen
Please provide more information on the steps leading up to the error that 
you get.
1. Is the login form showing?
2. Can you submit the form?
3. Do you get the error back from your login method - wrong e-mail or 
password?
4. Something else?

Suggest that you at least create the users table and add one user, so that 
CakePHP has something to work with.

Enjoy, John

On Wednesday, 17 December 2014 14:14:43 UTC+2, tech_me wrote:

 I posted to SO several days ago, but no expected replies.
 http://stackoverflow.com/q/27403391

 I am now using PHPTAL http://phptal.org/ which use html instead of ctp 
 files.
 Is there anyone who use the html files to cooperate with Cake's 
 authentication?

 Thanks.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


CakePHP 2.0 authentication(login) without ctp files but other types

2014-12-17 Thread tech_me
I posted to SO several days ago, but no expected replies.
http://stackoverflow.com/q/27403391

I am now using PHPTAL http://phptal.org/ which use html instead of ctp 
files.
Is there anyone who use the html files to cooperate with Cake's 
authentication?

Thanks.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.4 Auth-login() always return TRUE ... ?

2014-12-08 Thread Yomi Ojo


On Wednesday, April 16, 2014 5:59:47 PM UTC+1, euromark wrote:

 You are like the 400th person who didnt read that part of the 
 documentation in 2.x

 http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in
 (red warning box)

 if ($this-Auth-login($this-request-data['User'])) {}
 always logs this data in

 you need:

 if ($this-Auth-login()) {}



 Am Dienstag, 15. April 2014 13:46:56 UTC+2 schrieb MedAL:

 Hello,Iread the documentation to create a simple login form.each time I 
 try to log in it returns true  always;

 //UsersController
 public function login() { 
  if ($this-Auth-user()) {
 $this-redirect($this-Auth-redirect());
 }

 if ($this-request-is('post')) {

  $this-Auth-authenticate['Form'] = array('fields' = 
 array('username' = 'username'));
  $this-request-data['User']['id'] = $this-User-id; 
  debug($this-request-data);
 if ($this-Auth-login($this-request-data['User'])) {
  $this-Session-setFlash(sprintf(Welcome %s!, 
 $this-Auth-user('username')));
 return $this-redirect($this-Auth-redirect());
 }
 $this-Session-setFlash(__('Invalid username or password, try 
 again'));
 }
 }





 //AppController
 class AppController extends Controller {

 public $components = array(
 'Session',
 'Auth' = array(
 'loginRedirect' = array(
 'controller' = 'Events',
 'action' = 'index'
 ),
 'loginAction' = array('controller' = 'Users', 'action' = 
 'login'),

 'logoutRedirect' = array(
 'controller' = 'Users',
 'action' = 'login',
 'home'
 ),'authorize' = array('Controller')

 )
 );

 public function beforeFilter() {
 //parent::beforeFilter();
 $this-Auth-allow('index', 'view','login');
 /* $this-Auth-authenticate = array(
 'Basic' = array('userModel' = 'User'),
 'Form' = array('userModel' = 'User')
 );*/

 }



 //login.ctp


 div class=users form
 ?php echo $this-Session-flash('auth'); ?

 ?php echo $this-Form-create('User'); ?

 fieldset
 legend
 ?php echo __('Please enter your username and password'); ?
 /legend
 ?php echo $this-Form-input('username'); 
 echo $this-Form-input('password');
 ?
 /fieldset
 ?php echo $this-Form-end(__('Login')); ?
 /div



Thanks Euromark, I am the 401th person. It was really helpful  and useful  

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Plugin login problem

2014-11-17 Thread Jose
The Form::create() call was done incorrectly, it should be:

$this-Form-create('User', array('url' = array('admin' = false, 'plugin' 
= null, 'controller' = 'users', 'action' = 'login')));


On Thursday, November 6, 2014 5:11:36 AM UTC-5, Lucky1968 wrote:

 Hi,

 I'm using CakePHP 2.3.10 and I have a problem with a login form in my 
 header.
 When the login form is used from within a plugin view it sends the form to 
 /plugin_name/users/login instead of to /users/login.

 I have found numerous posts on this topic and all state the same: I need 
 to add *'plugin' = null* or *'plugin' = false* at some places. But that 
 I did already from the beginning and I still have the problem.

 Can anyone tell me what's wrong with my code?

 Here's my code:

 AppController.php
 public function beforeFilter() {
 ...
 $this-Auth-loginAction = array(*'plugin' = null*, 'controller' = 
 'users', 'action' = 'login');
 ...
 }

 UsersController.php
 public function beforeFilter() {
 parent::beforeFilter();
 ...
 }

 PluginAppController.php
 public function beforeFilter() {
 parent::beforeFilter();
 }

 In the element used by the selected layout:
 ?php echo $this-Form-create('User', array('admin' = false, *'plugin' 
 = null*, 'controller' = 'users', 'action' = 'login')); ?

 I also tried with *'plugin' = false* but the results are the same.

 Thanks for any help.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Plugin login problem

2014-11-06 Thread Lucky1968
Hi,

I'm using CakePHP 2.3.10 and I have a problem with a login form in my 
header.
When the login form is used from within a plugin view it sends the form to 
/plugin_name/users/login instead of to /users/login.

I have found numerous posts on this topic and all state the same: I need to 
add *'plugin' = null* or *'plugin' = false* at some places. But that I 
did already from the beginning and I still have the problem.

Can anyone tell me what's wrong with my code?

Here's my code:

AppController.php
public function beforeFilter() {
...
$this-Auth-loginAction = array(*'plugin' = null*, 'controller' = 
'users', 'action' = 'login');
...
}

UsersController.php
public function beforeFilter() {
parent::beforeFilter();
...
}

PluginAppController.php
public function beforeFilter() {
parent::beforeFilter();
}

In the element used by the selected layout:
?php echo $this-Form-create('User', array('admin' = false, *'plugin' = 
null*, 'controller' = 'users', 'action' = 'login')); ?

I also tried with *'plugin' = false* but the results are the same.

Thanks for any help.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Web service login function to check authenticate user in cakephp

2014-10-14 Thread John Andersen
The error message clearly states that the issue is with the missing Posts 
controller. But you states that the method is in the Users controller. 
Check your code.
Enjoy, John

On Saturday, 11 October 2014 00:33:54 UTC+3, Sam wrote:

 I am writing a web service to authenticate whether a user login is valid 
 or not. Below is a simple implementation of the web service placed inside 
 UsersController.php

 [snip]


 It does not work. The error message I received is something like this;

 \n\tError: \n\tPostsController could not be found.

 \n
 \n\tError: \n\tCreate the class PostsController below in file: 
 app\\Controller\\PostsController.php

 [snip]



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


RE: Web service login function to check authenticate user in cakephp

2014-10-11 Thread Saran
Hi Sam,

First thing is that you should used the restful technique that is already in 
CakePHP.

Please go through http://book.cakephp.org/2.0/en/development/rest.html

Now focus on your problem

Yes, you can use the Auth-login but the things is notice how you are posting 
your data, here I am talking about post data array format. Please dump post 
variable that help to solve the issue.

Kind regards
Saran
Sr. Web Developer 

-Original Message-
From: Radharadhya Dasa r...@krisna.hu
Sent: ‎11-‎10-‎2014 11:28 AM
To: cake-php@googlegroups.com cake-php@googlegroups.com
Subject: Re: Web service login function to check authenticate user in cakephp

There is a good chance that the error is not here, but in the code what calls 
this. So please show the code which calls calls the webservice. 
rrd 
2014.10.11. 3:56 ezt írta (Sam lightai...@gmail.com):

It is cakephp 2.5

On Saturday, October 11, 2014 9:53:21 AM UTC+8, Matthew Kaufman wrote:
Is this Cake 2.6 or 3?


On Fri, Oct 10, 2014 at 5:33 PM, Sam light...@gmail.com wrote:

I am writing a web service to authenticate whether a user login is valid or 
not. Below is a simple implementation of the web service placed inside 
UsersController.php
public function webservice_login() 
{
$this-autoRender = false;
if ($this-request-is('post')) 
{   
if ($this-Auth-login()) 
{
echo json_encode(array('ok_msg' = 'User authentication success'));
}
else
{
echo json_encode(array('fail_msg' = 'User authentication 
failure'));
}
} 
} It does not work. The error message I received is something like this;
\n\tError: \n\tPostsController could not be found.

\n
\n\tError: \n\tCreate the class PostsController below in file: 
app\\Controller\\PostsController.php

\n
\n?php\nclass PostsController extends AppController {\n\n}\n
\n
\n\tNotice: \n\tIf you want to customize this error message, create 
app\\View\\Errors\\missing_controller.ctpWhat is wrong with the code? How 
should I rewrite the web service? I am using Cakephp 2.5. Strange thing is I do 
not have a controller called Post in the first place.
-- 
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+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Web service login function to check authenticate user in cakephp

2014-10-10 Thread Sam


I am writing a web service to authenticate whether a user login is valid or 
not. Below is a simple implementation of the web service placed inside 
UsersController.php

public function webservice_login() {
$this-autoRender = false;
if ($this-request-is('post')) 
{   
if ($this-Auth-login()) 
{
echo json_encode(array('ok_msg' = 'User authentication success'));
}
else
{
echo json_encode(array('fail_msg' = 'User authentication 
failure'));
}
} } 

It does not work. The error message I received is something like this;

\n\tError: \n\tPostsController could not be found.

\n
\n\tError: \n\tCreate the class PostsController below in file: 
app\\Controller\\PostsController.php

\n
\n?php\nclass PostsController extends AppController {\n\n}\n
\n
\n\tNotice: \n\tIf you want to customize this error message, create 
app\\View\\Errors\\missing_controller.ctp

What is wrong with the code? How should I rewrite the web service? I am 
using Cakephp 2.5. Strange thing is I do not have a controller called Post 
in the first place.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Web service login function to check authenticate user in cakephp

2014-10-10 Thread Sam
It is cakephp 2.5

On Saturday, October 11, 2014 9:53:21 AM UTC+8, Matthew Kaufman wrote:

 Is this Cake 2.6 or 3?

 On Fri, Oct 10, 2014 at 5:33 PM, Sam light...@gmail.com javascript: 
 wrote:

 I am writing a web service to authenticate whether a user login is valid 
 or not. Below is a simple implementation of the web service placed inside 
 UsersController.php

 public function webservice_login() {
 $this-autoRender = false;
 if ($this-request-is('post')) 
 {   
 if ($this-Auth-login()) 
 {
 echo json_encode(array('ok_msg' = 'User authentication 
 success'));
 }
 else
 {
 echo json_encode(array('fail_msg' = 'User authentication 
 failure'));
 }
 } } 

 It does not work. The error message I received is something like this;

 \n\tError: \n\tPostsController could not be found.

 \n
 \n\tError: \n\tCreate the class PostsController below in file: 
 app\\Controller\\PostsController.php

 \n
 \n?php\nclass PostsController extends AppController {\n\n}\n
 \n
 \n\tNotice: \n\tIf you want to customize this error message, create 
 app\\View\\Errors\\missing_controller.ctp

 What is wrong with the code? How should I rewrite the web service? I am 
 using Cakephp 2.5. Strange thing is I do not have a controller called Post 
 in the first place.

 -- 
 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+u...@googlegroups.com javascript:.
 To post to this group, send email to cake...@googlegroups.com 
 javascript:.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Web service login function to check authenticate user in cakephp

2014-10-10 Thread Radharadhya Dasa
There is a good chance that the error is not here, but in the code what
calls this. So please show the code which calls calls the webservice.

rrd
2014.10.11. 3:56 ezt írta (Sam lightai...@gmail.com):

 It is cakephp 2.5

 On Saturday, October 11, 2014 9:53:21 AM UTC+8, Matthew Kaufman wrote:

 Is this Cake 2.6 or 3?

 On Fri, Oct 10, 2014 at 5:33 PM, Sam light...@gmail.com wrote:

 I am writing a web service to authenticate whether a user login is valid
 or not. Below is a simple implementation of the web service placed inside
 UsersController.php

 public function webservice_login() {
 $this-autoRender = false;
 if ($this-request-is('post'))
 {
 if ($this-Auth-login())
 {
 echo json_encode(array('ok_msg' = 'User authentication 
 success'));
 }
 else
 {
 echo json_encode(array('fail_msg' = 'User authentication 
 failure'));
 }
 } }

 It does not work. The error message I received is something like this;

 \n\tError: \n\tPostsController could not be found.

 \n
 \n\tError: \n\tCreate the class PostsController below in file: 
 app\\Controller\\PostsController.php

 \n
 \n?php\nclass PostsController extends AppController {\n\n}\n
 \n
 \n\tNotice: \n\tIf you want to customize this error message, create 
 app\\View\\Errors\\missing_controller.ctp

 What is wrong with the code? How should I rewrite the web service? I am
 using Cakephp 2.5. Strange thing is I do not have a controller called Post
 in the first place.

 --
 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+u...@googlegroups.com.
 To post to this group, send email to cake...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.


  --
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/d/optout.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cant use email as login cakephp

2014-08-07 Thread ajt
Hi,

I started it again and the problem was I had email as the username field. 
Cakephp is looking for username

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cant use email as login cakephp

2014-08-06 Thread Hakim Miah
Delete and start again and follow the example exactly in the cakephp 
documentation...

On Tuesday, 5 August 2014 08:38:19 UTC+1, ajt wrote:

 This function wont work as I get no output

  public function isAuthorized($user) {
 // Admin can access every action
 debug($user['role']);
 debug(asdd);





-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cant use email as login cakephp

2014-08-06 Thread Stephen S
What you have looks fine to me, first thing I would do is the following:

public function isAuthorized($user) {
pr($user);
die();
}

If isAuthorized gets called it'll kill the process and you can see the
output of user, if not something went wrong before then and we may need
more info to help.


On 6 August 2014 09:41, Hakim Miah hakim.miah.7...@gmail.com wrote:

 Delete and start again and follow the example exactly in the cakephp
 documentation...


 On Tuesday, 5 August 2014 08:38:19 UTC+1, ajt wrote:

 This function wont work as I get no output

  public function isAuthorized($user) {
 // Admin can access every action
 debug($user['role']);
 debug(asdd);



  --
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/d/optout.




-- 
Kind Regards
 Stephen Speakman

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cant use email as login cakephp

2014-08-06 Thread José Lorenzo
That is most probably becuase you are calling $this-Auth-login($data); 
The login method will log users in when you pass an argument to it. If you 
want authentication to be checked against database, just call 
$this-Auth-login() without arguments

On Wednesday, August 6, 2014 10:59:15 AM UTC+2, Stephen S wrote:

 What you have looks fine to me, first thing I would do is the following:

 public function isAuthorized($user) {
 pr($user);
 die();
 }

 If isAuthorized gets called it'll kill the process and you can see the 
 output of user, if not something went wrong before then and we may need 
 more info to help.


 On 6 August 2014 09:41, Hakim Miah hakim.miah.7...@gmail.com wrote:

 Delete and start again and follow the example exactly in the cakephp 
 documentation...


 On Tuesday, 5 August 2014 08:38:19 UTC+1, ajt wrote:

 This function wont work as I get no output

  public function isAuthorized($user) {
 // Admin can access every action
 debug($user['role']);
 debug(asdd);



  -- 
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Kind Regards
  Stephen Speakman
  

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cant use email as login cakephp

2014-08-05 Thread José Lorenzo
the problem is that you are not able to log in?

On Tuesday, August 5, 2014 5:38:45 AM UTC+2, ajt wrote:

 Hi, I cant authenticate users when I login in using appcontroller code . I 
 login with a non admin role and I still get through. . In fact I dont get 
 any error and no debug value appears so the isAuthorized($user) doesnt 
 work.l use the same code without email and used username in another website 
 and it works fine. I looked at the code from the docs and really couldnt 
 see the issue. The fields in the users table have role, email,password. 
 Since the same code worked elsewhere without email for username then I am 
 stuck on what to do as i checked how you add email as username in 
 $components.

 I have a user with a role called teacher that always logs in when it 
 shouldnt and I have simple password enabled. I checked email and role 
 values in database and all is as expected.


 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

  public $components = array(
  Email,
 'Session',
 'Auth' = array(
 'loginRedirect' = array('controller' = 'users', 'action' = 
 'dashboard'),
 'logoutRedirect' = array('controller' = 'users','action' = 'login' 
  ),
  'authenticate' = array( 'Form' = array('fields' = 
 array('username' = 'email') ,
  'authorize' = array('Controller') // Added this line
 ;


 public function isAuthorized($user) {
 // Admin can access every action
 debug($user['role']);  NO output
 debug(asdd); NO output

 if (isset($user['role'])  $user['role'] === 'admin') {
 return true;
 }

 // Default deny
 return false;
 } 



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cant use email as login cakephp

2014-08-05 Thread ajt

the problem is that I can log in with any user when I shouldnt. if the user 
isnt admin it will still access admin only webpages.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cant use email as login cakephp

2014-08-05 Thread ajt
This function wont work as I get no output

 public function isAuthorized($user) {
// Admin can access every action
debug($user['role']);
debug(asdd);





-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


cant use email as login cakephp

2014-08-04 Thread ajt
 

Hi, I cant authenticate users when I login in using appcontroller code . I 
login with a non admin role and I still get through. . In fact I dont get 
any error and no debug value appears so the isAuthorized($user) doesnt 
work.l use the same code without email and used username in another website 
and it works fine. I looked at the code from the docs and really couldnt 
see the issue. The fields in the users table have role, email,password. 
Since the same code worked elsewhere without email for username then I am 
stuck on what to do as i checked how you add email as username in 
$components.

I have a user with a role called teacher that always logs in when it 
shouldnt and I have simple password enabled. I checked email and role 
values in database and all is as expected.

http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

 public $components = array(
 Email,
'Session',
'Auth' = array(
'loginRedirect' = array('controller' = 'users', 'action' = 
'dashboard'),
'logoutRedirect' = array('controller' = 'users','action' = 'login'  
),
 'authenticate' = array( 'Form' = array('fields' = array('username' 
= 'email') ,
 'authorize' = array('Controller') // Added this line
;


public function isAuthorized($user) {
// Admin can access every action
debug($user['role']);  NO output
debug(asdd); NO output

if (isset($user['role'])  $user['role'] === 'admin') {
return true;
}

// Default deny
return false;
} 

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP Login redirect

2014-07-09 Thread Gagik Navasardyan
OK, I think this is the most suitable workaround for this case.

Thank you very much.

On Wednesday, July 9, 2014 4:01:37 AM UTC+10, bugoy wrote:

 Good point, though you can set the proper redirect in the function login() 
 in UserController, what is destroyed in logout for Session is Auth. You may 
 set a separate Session or Cookie for last logged user and check if same 
 with the current user the redirect Auth-redirect else redirect anywhere 
 else. 


 On Sat, Jul 5, 2014 at 10:31 PM, Gagik Navasardyan gag...@gmail.com 
 javascript: wrote:

 Yes I'm sure that the Auth-logout action is being called, and the old 
 session is certainly being destroyed too, before the new session is created.

 - I tried to rewrite the 'Auth.redirect' property before the Auth-logout 
 action call, it have no effect because session is being destroyed. 
 - I tried to rewrite that property after the Auth-logout call, of course 
 it have no effect either, because as I understand after  the Auth-logout 
 call the script terminates (by calling return).

 I made a little research and found the following code in path to 
 CakePHP/lib/Cake/Controller/Component/AuthComponent.php (protected 
 function _unauthenticated)


 if ($this-_isLoginAction($controller)) { 
 if (empty($controller-request-data)) { 
 if (!$this-Session-check('Auth.redirect')  
 env('HTTP_REFERER')) { 
 $this-Session-write('Auth.redirect', 
 $controller-referer(null, true)); 
 } 
 } 
 return true; 
 }

 It seems to me that this code is responsible for users login, as we can 
 understand from code:
 - if user doesn't have the 'Auth.redirect' property set, means this is a 
 new(not logged in) user who needs to login in order to view restricted 
 content(for example after search) or user whom session is expired, then 
 CakePHP redirects the user on the page on which he was before. And this is 
 really a good idea.

 But as I understand this is creating my problem, because after the 
 Auth-logout action call  Session is being destroyed, means there is no 
 'Auth.redirect' property, so CakePHP setting the 'Auth.redirect' from HTTP 
 referer, and as I said this is good if user is coming from any place and 
 needs to login(again for example from search), or user session is expired, 
 but if user clicks the logout link and logs out he doesn't expect that 
 after loging-in again he will return on the page on which he was before, he 
 must be redirected not to the HTTP referer page, but the 'loginRedirect' 
 page.

  

 On Tuesday, 1 July 2014 13:14:48 UTC+10, Jeremy Burns wrote:

 Are you certain the Auth-logout action is being called? Is the session 
 clear (destroyed) after logout?

 On 28 Jun 2014, at 12:54, Gagik Navasardyan gag...@gmail.com wrote:

 Hi everyone.

 I have one question. 

 I'm working on an application which is working in local network and 
 acting as POS(Point of Sale). As you understand it's based on CakePHP 
 framework.
 Now I'm encountering a strange behaviour, and I don't know is it a bug 
 or not, so I've decided to ask you a question here.

 - I'm using CakePHP 2.4.2 and the built-in AuthComponent for 
 authentication

 - *The thing is,* after user logs out and another user logs in (using 
 the same computer and browser), he is being redirected to the page on which 
 the previous user was when logged out. Instead of being redirected to the 
 URL defined in 'loginRedirect'

 - In this application I'm using role based user permissions system, and 
 the most of time system throwing permission error, because newly logged in 
 user doesn't have permission to view the page on which previous user was 
 when logged out.

 This behaviour is very strange to me, because as I know the logout 
 function is destroying session, but it seems keeping the last visited URL 
 of the previous user in the 'Auth.redirect' property in the new session.
 This seems a little bit strange to me, because I'm expecting this kind 
 of redirect in a few cases like:
 - If user session expired and user have to login again.
 - user trying to access to a page which is requiring authentication.  

 I analised the code and clearly the problem is in the framework core, 
 and there is no way to rewrite the 'Auth.redirect' property either before 
 or after the 'logout' function call (in any case the session being 
 destroyed and as I understand CakePHP taking and writing the last visited 
 page URL to the new session from HTTP REFERER).


 So question:
 Is this a Normal behaviour, and there are some reason why this must be 
 this way, or this is a bug?

 -- 
 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+u...@googlegroups.com.
 To post

Re: CakePHP Login redirect

2014-07-08 Thread francis declaro
Good point, though you can set the proper redirect in the function login()
in UserController, what is destroyed in logout for Session is Auth. You may
set a separate Session or Cookie for last logged user and check if same
with the current user the redirect Auth-redirect else redirect anywhere
else.


On Sat, Jul 5, 2014 at 10:31 PM, Gagik Navasardyan gag...@gmail.com wrote:

 Yes I'm sure that the Auth-logout action is being called, and the old
 session is certainly being destroyed too, before the new session is created.

 - I tried to rewrite the 'Auth.redirect' property before the Auth-logout
 action call, it have no effect because session is being destroyed.
 - I tried to rewrite that property after the Auth-logout call, of course
 it have no effect either, because as I understand after  the Auth-logout
 call the script terminates (by calling return).

 I made a little research and found the following code in path to
 CakePHP/lib/Cake/Controller/Component/AuthComponent.php (protected
 function _unauthenticated)


 if ($this-_isLoginAction($controller)) {
 if (empty($controller-request-data)) {
 if (!$this-Session-check('Auth.redirect') 
 env('HTTP_REFERER')) {
 $this-Session-write('Auth.redirect',
 $controller-referer(null, true));
 }
 }
 return true;
 }

 It seems to me that this code is responsible for users login, as we can
 understand from code:
 - if user doesn't have the 'Auth.redirect' property set, means this is a
 new(not logged in) user who needs to login in order to view restricted
 content(for example after search) or user whom session is expired, then
 CakePHP redirects the user on the page on which he was before. And this is
 really a good idea.

 But as I understand this is creating my problem, because after the
 Auth-logout action call  Session is being destroyed, means there is no
 'Auth.redirect' property, so CakePHP setting the 'Auth.redirect' from HTTP
 referer, and as I said this is good if user is coming from any place and
 needs to login(again for example from search), or user session is expired,
 but if user clicks the logout link and logs out he doesn't expect that
 after loging-in again he will return on the page on which he was before, he
 must be redirected not to the HTTP referer page, but the 'loginRedirect'
 page.



 On Tuesday, 1 July 2014 13:14:48 UTC+10, Jeremy Burns wrote:

 Are you certain the Auth-logout action is being called? Is the session
 clear (destroyed) after logout?

 On 28 Jun 2014, at 12:54, Gagik Navasardyan gag...@gmail.com wrote:

 Hi everyone.

 I have one question.

 I'm working on an application which is working in local network and
 acting as POS(Point of Sale). As you understand it's based on CakePHP
 framework.
 Now I'm encountering a strange behaviour, and I don't know is it a bug or
 not, so I've decided to ask you a question here.

 - I'm using CakePHP 2.4.2 and the built-in AuthComponent for
 authentication

 - *The thing is,* after user logs out and another user logs in (using
 the same computer and browser), he is being redirected to the page on which
 the previous user was when logged out. Instead of being redirected to the
 URL defined in 'loginRedirect'

 - In this application I'm using role based user permissions system, and
 the most of time system throwing permission error, because newly logged in
 user doesn't have permission to view the page on which previous user was
 when logged out.

 This behaviour is very strange to me, because as I know the logout
 function is destroying session, but it seems keeping the last visited URL
 of the previous user in the 'Auth.redirect' property in the new session.
 This seems a little bit strange to me, because I'm expecting this kind of
 redirect in a few cases like:
 - If user session expired and user have to login again.
 - user trying to access to a page which is requiring authentication.

 I analised the code and clearly the problem is in the framework core, and
 there is no way to rewrite the 'Auth.redirect' property either before or
 after the 'logout' function call (in any case the session being destroyed
 and as I understand CakePHP taking and writing the last visited page URL to
 the new session from HTTP REFERER).


 So question:
 Is this a Normal behaviour, and there are some reason why this must be
 this way, or this is a bug?

 --
 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+u...@googlegroups.com.
 To post to this group, send email to cake...@googlegroups.com.

 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.


  --
 Like Us on FaceBook https://www.facebook.com

Re: CakePHP Login redirect

2014-07-07 Thread Gagik Navasardyan
Yes I'm sure that the Auth-logout action is being called, and the old 
session is certainly being destroyed too, before the new session is created.

- I tried to rewrite the 'Auth.redirect' property before the Auth-logout 
action call, it have no effect because session is being destroyed. 
- I tried to rewrite that property after the Auth-logout call, of course 
it have no effect either, because as I understand after  the Auth-logout 
call the script terminates (by calling return).

I made a little research and found the following code in path to 
CakePHP/lib/Cake/Controller/Component/AuthComponent.php (protected 
function _unauthenticated)


if ($this-_isLoginAction($controller)) { 
if (empty($controller-request-data)) { 
if (!$this-Session-check('Auth.redirect')  
env('HTTP_REFERER')) { 
$this-Session-write('Auth.redirect', 
$controller-referer(null, true)); 
} 
} 
return true; 
}

It seems to me that this code is responsible for users login, as we can 
understand from code:
- if user doesn't have the 'Auth.redirect' property set, means this is a 
new(not logged in) user who needs to login in order to view restricted 
content(for example after search) or user whom session is expired, then 
CakePHP redirects the user on the page on which he was before. And this is 
really a good idea.

But as I understand this is creating my problem, because after the 
Auth-logout action call  Session is being destroyed, means there is no 
'Auth.redirect' property, so CakePHP setting the 'Auth.redirect' from HTTP 
referer, and as I said this is good if user is coming from any place and 
needs to login(again for example from search), or user session is expired, 
but if user clicks the logout link and logs out he doesn't expect that 
after loging-in again he will return on the page on which he was before, he 
must be redirected not to the HTTP referer page, but the 'loginRedirect' 
page.
 

On Tuesday, 1 July 2014 13:14:48 UTC+10, Jeremy Burns wrote:

 Are you certain the Auth-logout action is being called? Is the session 
 clear (destroyed) after logout?

 On 28 Jun 2014, at 12:54, Gagik Navasardyan gag...@gmail.com 
 javascript: wrote:

 Hi everyone.

 I have one question. 

 I'm working on an application which is working in local network and acting 
 as POS(Point of Sale). As you understand it's based on CakePHP framework.
 Now I'm encountering a strange behaviour, and I don't know is it a bug or 
 not, so I've decided to ask you a question here.

 - I'm using CakePHP 2.4.2 and the built-in AuthComponent for authentication

 - *The thing is,* after user logs out and another user logs in (using the 
 same computer and browser), he is being redirected to the page on which the 
 previous user was when logged out. Instead of being redirected to the URL 
 defined in 'loginRedirect'

 - In this application I'm using role based user permissions system, and 
 the most of time system throwing permission error, because newly logged in 
 user doesn't have permission to view the page on which previous user was 
 when logged out.

 This behaviour is very strange to me, because as I know the logout 
 function is destroying session, but it seems keeping the last visited URL 
 of the previous user in the 'Auth.redirect' property in the new session.
 This seems a little bit strange to me, because I'm expecting this kind of 
 redirect in a few cases like:
 - If user session expired and user have to login again.
 - user trying to access to a page which is requiring authentication.  

 I analised the code and clearly the problem is in the framework core, and 
 there is no way to rewrite the 'Auth.redirect' property either before or 
 after the 'logout' function call (in any case the session being destroyed 
 and as I understand CakePHP taking and writing the last visited page URL to 
 the new session from HTTP REFERER).


 So question:
 Is this a Normal behaviour, and there are some reason why this must be 
 this way, or this is a bug?

 -- 
 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+u...@googlegroups.com javascript:.
 To post to this group, send email to cake...@googlegroups.com 
 javascript:.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php

CakePHP Login redirect

2014-06-30 Thread Gagik Navasardyan
Hi everyone.

I have one question. 

I'm working on an application which is working in local network and acting 
as POS(Point of Sale). As you understand it's based on CakePHP framework.
Now I'm encountering a strange behaviour, and I don't know is it a bug or 
not, so I've decided to ask you a question here.

- I'm using CakePHP 2.4.2 and the built-in AuthComponent for authentication

- *The thing is,* after user logs out and another user logs in (using the 
same computer and browser), he is being redirected to the page on which the 
previous user was when logged out. Instead of being redirected to the URL 
defined in 'loginRedirect'

- In this application I'm using role based user permissions system, and the 
most of time system throwing permission error, because newly logged in user 
doesn't have permission to view the page on which previous user was when 
logged out.

This behaviour is very strange to me, because as I know the logout function 
is destroying session, but it seems keeping the last visited URL of the 
previous user in the 'Auth.redirect' property in the new session.
This seems a little bit strange to me, because I'm expecting this kind of 
redirect in a few cases like:
- If user session expired and user have to login again.
- user trying to access to a page which is requiring authentication.  

I analised the code and clearly the problem is in the framework core, and 
there is no way to rewrite the 'Auth.redirect' property either before or 
after the 'logout' function call (in any case the session being destroyed 
and as I understand CakePHP taking and writing the last visited page URL to 
the new session from HTTP REFERER).


So question:
Is this a Normal behaviour, and there are some reason why this must be this 
way, or this is a bug?

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP Login redirect

2014-06-30 Thread Jeremy Burns : Class Outfit
Are you certain the Auth-logout action is being called? Is the session clear 
(destroyed) after logout?

On 28 Jun 2014, at 12:54, Gagik Navasardyan gag...@gmail.com wrote:

 Hi everyone.
 
 I have one question. 
 
 I'm working on an application which is working in local network and acting as 
 POS(Point of Sale). As you understand it's based on CakePHP framework.
 Now I'm encountering a strange behaviour, and I don't know is it a bug or 
 not, so I've decided to ask you a question here.
 
 - I'm using CakePHP 2.4.2 and the built-in AuthComponent for authentication
 
 - The thing is, after user logs out and another user logs in (using the same 
 computer and browser), he is being redirected to the page on which the 
 previous user was when logged out. Instead of being redirected to the URL 
 defined in 'loginRedirect'
 
 - In this application I'm using role based user permissions system, and the 
 most of time system throwing permission error, because newly logged in user 
 doesn't have permission to view the page on which previous user was when 
 logged out.
 
 This behaviour is very strange to me, because as I know the logout function 
 is destroying session, but it seems keeping the last visited URL of the 
 previous user in the 'Auth.redirect' property in the new session.
 This seems a little bit strange to me, because I'm expecting this kind of 
 redirect in a few cases like:
 - If user session expired and user have to login again.
 - user trying to access to a page which is requiring authentication.  
 
 I analised the code and clearly the problem is in the framework core, and 
 there is no way to rewrite the 'Auth.redirect' property either before or 
 after the 'logout' function call (in any case the session being destroyed and 
 as I understand CakePHP taking and writing the last visited page URL to the 
 new session from HTTP REFERER).
 
 
 So question:
 Is this a Normal behaviour, and there are some reason why this must be this 
 way, or this is a bug?
 
 -- 
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: My $this-Auth-login() does not work, any help please? :) Cakephp 2.5.1

2014-06-24 Thread Zero Sony
Hi all,

Finaly, i found the solutions. I made a big mistake in my Form. I write 
username  and passwordinstead of username and password. Cake 
took the space after username and password.
Thx all for your help. =)

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: My $this-Auth-login() does not work, any help please? :) Cakephp 2.5.1

2014-06-19 Thread José Lorenzo
Can you share your code via gist.github.com instead?

On Wednesday, June 18, 2014 5:39:02 PM UTC+2, Zero Sony wrote:

 Hi all, 

 I use cakephp 2.5.1 and my  $this-Auth-login()   does not work. It 
 return me false each time.
 Maybe if someone can say me why , i ll be very gratefull ^^
 I m on this problem for severals days T_T

 My DB is called  users and there are fields username and password .

 *AppControler*

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 class AppController extends Controller {
  
 public $components = array('Session', 'Cookie',
 'Auth' = array(
 'authenticate' = array('Form'code class=php plain 
 style=font-variant: inherit; outline: 0px !important; font-family: 
 Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace 
 !important; line-height: 1.4em !important; border-top-left-radius: 0px 
 !important; border-top-right-radius: 0px !important; 
 border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px 
 !important; bottom: auto !important; float: none !important; height: auto 
 !important; left: auto !important; overflow: visible !important; position: 
 static !important; right: auto !important; top: auto !important; width: 
 auto !important; box-sizing: content-box !impo
 ...

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: My $this-Auth-login() does not work, any help please? :) Cakephp 2.5.1

2014-06-19 Thread Zero Sony
https://gist.github.com/0-Sony/3c052a832687e8dbb4d7

Thx for your help!



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: My $this-Auth-login() does not work, any help please? :) Cakephp 2.5.1

2014-06-19 Thread euromark
Mind your casing

'Authenticate' = 'form'

Compare this with what is documented:
http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#configuring-authentication-handlers

mark



Am Donnerstag, 19. Juni 2014 15:32:53 UTC+2 schrieb Zero Sony:

 https://gist.github.com/0-Sony/3c052a832687e8dbb4d7

 Thx for your help!





-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: My $this-Auth-login() does not work, any help please? :) Cakephp 2.5.1

2014-06-19 Thread 0-SonY
I have just edited it. But it's still not work. T_T


2014-06-19 18:48 GMT+02:00 euromark dereurom...@gmail.com:

 Mind your casing

 'Authenticate' = 'form'

 Compare this with what is documented:

 http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#configuring-authentication-handlers

 mark



 Am Donnerstag, 19. Juni 2014 15:32:53 UTC+2 schrieb Zero Sony:

 https://gist.github.com/0-Sony/3c052a832687e8dbb4d7

 Thx for your help!



  --
 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 a topic in the
 Google Groups CakePHP group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/cake-php/etvRbrLTpxs/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 cake-php+unsubscr...@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.
 For more options, visit https://groups.google.com/d/optout.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: My $this-Auth-login() does not work, any help please? :) Cakephp 2.5.1

2014-06-19 Thread Zero Sony
Thx for your help.

I have just edited it. But it's still not work T_T


https://gist.github.com/0-Sony/3c052a832687e8dbb4d7


Le jeudi 19 juin 2014 18:48:05 UTC+2, euromark a écrit :

 Mind your casing

 'Authenticate' = 'form'

 Compare this with what is documented:

 http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#configuring-authentication-handlers

 mark



 Am Donnerstag, 19. Juni 2014 15:32:53 UTC+2 schrieb Zero Sony:

 https://gist.github.com/0-Sony/3c052a832687e8dbb4d7

 Thx for your help!





-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Trying to learn Auth and Login, can someone upload there files so i can analyze?

2014-06-11 Thread Jake
I would recommend taking a look at the Authake plugin on Github. It is a
little rough around the edges but does give an excellent starting point to
learn from and or extend as required. It provides group management and
regexp powered path rules that are easy to setup.

The fork by msbragi https://github.com/msbragi/authake has bug fixes and
support for SQLite, which can be ignored in favour of MySQL, but is also
informative.

There is also a popular plugin by CakeDC, but I haven't used it before.
Here is a link: https://github.com/CakeDC/users


js


On Tue, Jun 10, 2014 at 10:15 AM, Art Sir art...@gmail.com wrote:

 I followed the tutorial on the site but its hard putting it all together.
 And I have been trying to learn on and off. And I forget i have a full time
 job, learning this on the side.

 i just want to see how everything is layed out and i can tinker and modify
 so i can understand it. Like a start login and logout. And how the db is
 setup to add users.

 Thanks

 --
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/d/optout.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Trying to learn Auth and Login, can someone upload there files so i can analyze?

2014-06-10 Thread Art Sir
I followed the tutorial on the site but its hard putting it all together. 
And I have been trying to learn on and off. And I forget i have a full time 
job, learning this on the side.

i just want to see how everything is layed out and i can tinker and modify 
so i can understand it. Like a start login and logout. And how the db is 
setup to add users.

Thanks

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Trying to learn Auth and Login, can someone upload there files so i can analyze?

2014-06-10 Thread Reuben
Here are a couple of examples:

https://github.com/steinkel/cakephp-2.0-auth-example
https://github.com/josegonzalez/tutorial-role-auth-codebase

I googled cakephp auth github.

You might come across some Auth alternatives as well.

Regards
Reuben Helms

On Wednesday, 11 June 2014 00:15:42 UTC+10, Art Sir wrote:

 I followed the tutorial on the site but its hard putting it all together. 
 And I have been trying to learn on and off. And I forget i have a full time 
 job, learning this on the side.

 i just want to see how everything is layed out and i can tinker and modify 
 so i can understand it. Like a start login and logout. And how the db is 
 setup to add users.

 Thanks


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


cant login

2014-05-29 Thread jagguy
Hi,

I am learning how cakePHP does logins from this long example
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

I copied all the code in the files and there is a few files here.
Anyway I have 2 questions from that link

1) I cant get anything to login. I dont get an error but at the login 
screen I cant login with anything and also I go to add where I add a user 
and I get redirected back to the login screen.

I get from the login scren You are not authorized to access that location.


2) is the below code required in the User.php file as i didnt include this 
App::uses

// app/Model/User.php
App::uses('AppModel', 'Model');App::uses('SimplePasswordHasher', 
'Controller/Component/Auth');


-- 
 http://itfutures.edu.au?referer=email
*P: (03) 9866 7737*
*E: i...@itfutures.edu.au i...@itfutures.edu.au*
*A: Suite 5 / Level 1 / 424 St Kilda Rd, Melbourne, 3004 
https://www.google.com.au/url?sa=trct=jq=esrc=ssource=webcd=15cad=rjauact=8ved=0CKQBEPUXMA4url=http%3A%2F%2Fmaps.google.com.au%2Fmaps%3Fgl%3Dau%26hq%3Ditfutures%26daddr%3D1%2F424%2BSt%2BKilda%2BRd%2C%2BMelbourne%2BVIC%2B3004%26panel%3D1%26f%3Dd%26fb%3D1%26geocode%3DFdKovv0dMSWkCCnfp02hHWjWajGLbygrlMPvUw%26cid%3D6048267865728511883ei=hHUYU_abH8-okgXV7oGYDgusg=AFQjCNEBpgXrGRhNzMxOzPLHRVSQkdpXUQbvm=bv.62577051,d.dGI*


-- 
*Connect with us: *

http://plus.google.com/+itfutureseduau 
http://linkedin.com/company/it-futures
  http://youtube.com/user/itfutureseduau  http://twitter.com/itfutures 
http://facebook.com/itfutures

-- 


Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the Communication) is, unless 
otherwise stated, confidential,  may contain copyright material and is for 
the use only of the intended recipient. If you receive the Communication in 
error, please notify the sender immediately by return e-mail, delete the 
Communication and the return e-mail, and do not read, copy, retransmit or 
otherwise deal with it. Any views expressed in the Communication are those 
of the individual sender only, unless expressly stated to be those of 
National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any 
of its related entities. NTSP does not accept liability in connection with 
the integrity of or errors in the Communication, computer virus, data 
corruption, interference or delay arising from or in respect of the 
Communication.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cant login

2014-05-29 Thread jagguy
This the view I cant get out of

div class=users form
?php echo $this-Session-flash('auth'); ?
?php echo $this-Form-create('User'); ?
fieldset
legend
?php echo __('!! Please enter your username and password'); ?
/legend
?php echo $this-Form-input('username');
echo $this-Form-input('password');
?
/fieldset
?php echo $this-Form-end(__('Login')); ?
/div

-- 
 http://itfutures.edu.au?referer=email
*P: (03) 9866 7737*
*E: i...@itfutures.edu.au i...@itfutures.edu.au*
*A: Suite 5 / Level 1 / 424 St Kilda Rd, Melbourne, 3004 
https://www.google.com.au/url?sa=trct=jq=esrc=ssource=webcd=15cad=rjauact=8ved=0CKQBEPUXMA4url=http%3A%2F%2Fmaps.google.com.au%2Fmaps%3Fgl%3Dau%26hq%3Ditfutures%26daddr%3D1%2F424%2BSt%2BKilda%2BRd%2C%2BMelbourne%2BVIC%2B3004%26panel%3D1%26f%3Dd%26fb%3D1%26geocode%3DFdKovv0dMSWkCCnfp02hHWjWajGLbygrlMPvUw%26cid%3D6048267865728511883ei=hHUYU_abH8-okgXV7oGYDgusg=AFQjCNEBpgXrGRhNzMxOzPLHRVSQkdpXUQbvm=bv.62577051,d.dGI*


-- 
*Connect with us: *

http://plus.google.com/+itfutureseduau 
http://linkedin.com/company/it-futures
  http://youtube.com/user/itfutureseduau  http://twitter.com/itfutures 
http://facebook.com/itfutures

-- 


Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the Communication) is, unless 
otherwise stated, confidential,  may contain copyright material and is for 
the use only of the intended recipient. If you receive the Communication in 
error, please notify the sender immediately by return e-mail, delete the 
Communication and the return e-mail, and do not read, copy, retransmit or 
otherwise deal with it. Any views expressed in the Communication are those 
of the individual sender only, unless expressly stated to be those of 
National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any 
of its related entities. NTSP does not accept liability in connection with 
the integrity of or errors in the Communication, computer virus, data 
corruption, interference or delay arising from or in respect of the 
Communication.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


cakePhp 2.5 Auth login problem

2014-05-21 Thread earth
Hello,

I have a table named accounts having fields id, email and passwd.
In my AppController.php beforeFilter() function i have this code.

$this-Auth-authorize = array('Controllers');
$this-Auth-authenticate = array('all' = array('scope' = 
array('Account.enabled' = 'Y')), 'Form' = array('userModel' = 'Account', 
'fields' = array('username' = 'email', 'password' = 'passwd')));
$this-Auth-loginAction = array('controller' = 'accounts', 'action' = 
'login');
$this-Auth-logoutRedirect = array('controller' = 'accounts', 'action' = 
'login');
$this-Auth-allow(array('login', 'logout'));


After entering the correct login details in the login form 
(/accounts/login) i am getting this message You are not authorized to 
access that location..

Please let me know what i am doing wrong here and also how do i access the 
logged in user values in Views.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


How to redirect all webpages under webroot to login page?

2014-05-15 Thread Sam


I am using cakephp 2.4.5. I would like to redirect all users who have not 
logged in to a login page. I basically followed the instructions here 
http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

In summary, the important part is the following code to AppController.php

public $components = array('Session',
'Auth' = array(
'loginRedirect' = array('controller' = 
'users', 'action' = 'index'),
'logoutRedirect' = array('controller' = 
'users', 'action' = 'login'),
'authError' = 'You must be logged in to view 
this page.',
'loginError' = 'Invalid Username or Password 
entered, please try again.'
));

Any websites with this URL format 
http://localhost/cakephp245/controllers/XXX will be re-directed to the 
login page. However, websites that are located inside webroot with URL that 
looks like thishttp://localhost/TTSH-CP245/app/webroot/XXX will not be 
re-directed to the login page.

How can I get websites located inside app/webroot folder to be re-directed 
to the login page?

Thank you very much.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Redirect all webpages under webroot to login page

2014-05-15 Thread Sam


I am using cakephp 2.4.5. I would like to redirect all users who have not 
logged in to a login page. I basically followed the instructions here 
http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

In summary, the important part is the following code to AppController.php

public $components = array('Session',
'Auth' = array(
'loginRedirect' = array('controller' = 
'users', 'action' = 'index'),
'logoutRedirect' = array('controller' = 
'users', 'action' = 'login'),
'authError' = 'You must be logged in to view 
this page.',
'loginError' = 'Invalid Username or Password 
entered, please try again.'
));

Any websites with this URL format http://localhost/cakephp245/controllers/XXX 
will be re-directed to the login page. However, websites that are located 
inside webroot with URL that looks like 
thishttp://localhost/cakephp245/app/webroot/XXX will not be re-directed to the 
login page.

How can I force websites located inside app/webroot folder to be re-directed to 
the login page?

Thank you very much.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Redirect all webpages under webroot to login page

2014-05-15 Thread Reuben
Webpages located under app/webroot aren't subject to processing the same 
way that controllers are.

If you have static pages that require authentication, then I would suggest 
usage of the Pages controller 
(http://book.cakephp.org/2.0/en/controllers/pages-controller.html), and 
relocate those static pages under app/Views/Pages. You'll probably also 
need to update the extensions from .htm(l) to .ctp, and make use of the 
Router to allow the .htm(l) extension.

Regards
Reuben Helms

On Thursday, 15 May 2014 18:38:40 UTC+10, Sam wrote:

 I am using cakephp 2.4.5. I would like to redirect all users who have not 
 logged in to a login page. I basically followed the instructions here 
 http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

 In summary, the important part is the following code to AppController.php

 public $components = array('Session',
 'Auth' = array(
 'loginRedirect' = array('controller' = 
 'users', 'action' = 'index'),
 'logoutRedirect' = array('controller' = 
 'users', 'action' = 'login'),
 'authError' = 'You must be logged in to view 
 this page.',
 'loginError' = 'Invalid Username or Password 
 entered, please try again.'
 ));

 Any websites with this URL format http://localhost/cakephp245/controllers/XXX 
 will be re-directed to the login page. However, websites that are located 
 inside webroot with URL that looks like 
 thishttp://localhost/cakephp245/app/webroot/XXX will not be re-directed to 
 the login page.

 How can I force websites located inside app/webroot folder to be re-directed 
 to the login page?

 Thank you very much.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: Redirect all webpages under webroot to login page

2014-05-15 Thread Reuben
I might also suggest change the DocumentRoot of your application to 
app/webroot, since you probably shouldn't be accessing the controllers 
directory directly (unless it was just an example).

On Thursday, 15 May 2014 18:38:40 UTC+10, Sam wrote:

 I am using cakephp 2.4.5. I would like to redirect all users who have not 
 logged in to a login page. I basically followed the instructions here 
 http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

 In summary, the important part is the following code to AppController.php

 public $components = array('Session',
 'Auth' = array(
 'loginRedirect' = array('controller' = 
 'users', 'action' = 'index'),
 'logoutRedirect' = array('controller' = 
 'users', 'action' = 'login'),
 'authError' = 'You must be logged in to view 
 this page.',
 'loginError' = 'Invalid Username or Password 
 entered, please try again.'
 ));

 Any websites with this URL format http://localhost/cakephp245/controllers/XXX 
 will be re-directed to the login page. However, websites that are located 
 inside webroot with URL that looks like 
 thishttp://localhost/cakephp245/app/webroot/XXX will not be re-directed to 
 the login page.

 How can I force websites located inside app/webroot folder to be re-directed 
 to the login page?

 Thank you very much.



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


cakephp user login and administration page

2014-04-24 Thread archie rombo
Hello,
I'm new to cakephp, and i need to create a user registration page which 
after successful registration an admin user can login in and view the 
username of registered users, i have tried creating an application but it 
only displays user id and not username
Help would be appreciated.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: cakephp user login and administration page

2014-04-24 Thread Salines
Can you describe precisely where and what you want to show? 

Feel free to paste your code on https://gist.github.com/  or other pastebin 
services.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


CakePHP 2.4 Auth-login() always return TRUE ... ?

2014-04-16 Thread MedAL
Hello,Iread the documentation to create a simple login form.each time I try 
to log in it returns true  always;

//UsersController
public function login() { 
 if ($this-Auth-user()) {
$this-redirect($this-Auth-redirect());
}

if ($this-request-is('post')) {

 $this-Auth-authenticate['Form'] = array('fields' = array('username' 
= 'username'));
 $this-request-data['User']['id'] = $this-User-id; 
 debug($this-request-data);
if ($this-Auth-login($this-request-data['User'])) {
 $this-Session-setFlash(sprintf(Welcome %s!, 
$this-Auth-user('username')));
return $this-redirect($this-Auth-redirect());
}
$this-Session-setFlash(__('Invalid username or password, try 
again'));
}
}





//AppController
class AppController extends Controller {

public $components = array(
'Session',
'Auth' = array(
'loginRedirect' = array(
'controller' = 'Events',
'action' = 'index'
),
'loginAction' = array('controller' = 'Users', 'action' = 
'login'),

'logoutRedirect' = array(
'controller' = 'Users',
'action' = 'login',
'home'
),'authorize' = array('Controller')

)
);

public function beforeFilter() {
//parent::beforeFilter();
$this-Auth-allow('index', 'view','login');
/* $this-Auth-authenticate = array(
'Basic' = array('userModel' = 'User'),
'Form' = array('userModel' = 'User')
);*/

}



//login.ctp


div class=users form
?php echo $this-Session-flash('auth'); ?

?php echo $this-Form-create('User'); ?

fieldset
legend
?php echo __('Please enter your username and password'); ?
/legend
?php echo $this-Form-input('username'); 
echo $this-Form-input('password');
?
/fieldset
?php echo $this-Form-end(__('Login')); ?
/div

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.4 Auth-login() always return TRUE ... ?

2014-04-16 Thread euromark
You are like the 400th person who didnt read that part of the documentation 
in 2.x
http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in
(red warning box)

if ($this-Auth-login($this-request-data['User'])) {}
always logs this data in

you need:

if ($this-Auth-login()) {}



Am Dienstag, 15. April 2014 13:46:56 UTC+2 schrieb MedAL:

 Hello,Iread the documentation to create a simple login form.each time I 
 try to log in it returns true  always;

 //UsersController
 public function login() { 
  if ($this-Auth-user()) {
 $this-redirect($this-Auth-redirect());
 }

 if ($this-request-is('post')) {

  $this-Auth-authenticate['Form'] = array('fields' = 
 array('username' = 'username'));
  $this-request-data['User']['id'] = $this-User-id; 
  debug($this-request-data);
 if ($this-Auth-login($this-request-data['User'])) {
  $this-Session-setFlash(sprintf(Welcome %s!, 
 $this-Auth-user('username')));
 return $this-redirect($this-Auth-redirect());
 }
 $this-Session-setFlash(__('Invalid username or password, try 
 again'));
 }
 }





 //AppController
 class AppController extends Controller {

 public $components = array(
 'Session',
 'Auth' = array(
 'loginRedirect' = array(
 'controller' = 'Events',
 'action' = 'index'
 ),
 'loginAction' = array('controller' = 'Users', 'action' = 
 'login'),

 'logoutRedirect' = array(
 'controller' = 'Users',
 'action' = 'login',
 'home'
 ),'authorize' = array('Controller')

 )
 );

 public function beforeFilter() {
 //parent::beforeFilter();
 $this-Auth-allow('index', 'view','login');
 /* $this-Auth-authenticate = array(
 'Basic' = array('userModel' = 'User'),
 'Form' = array('userModel' = 'User')
 );*/

 }



 //login.ctp


 div class=users form
 ?php echo $this-Session-flash('auth'); ?

 ?php echo $this-Form-create('User'); ?

 fieldset
 legend
 ?php echo __('Please enter your username and password'); ?
 /legend
 ?php echo $this-Form-input('username'); 
 echo $this-Form-input('password');
 ?
 /fieldset
 ?php echo $this-Form-end(__('Login')); ?
 /div


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


CakePHP Ajax login

2014-04-07 Thread Ben Robey
I've started using Cakephp for a new project that I'm doing and I've become 
stuck on how to login using client side technologies. The application will 
be accessing cake via restful api calls and I'm trying to get the login 
working using ajax but am unsure of how to write the request. This is my 
login function in the UsersController:

public function login() {
if ((AuthComponent::user('id'))) {
$this-Session-setFlash(__('Warning: You are already logged in 
as ' . AuthComponent::user('username')));
}
if ($this-request-is('post')) {
if ($this-Auth-login()) {
return $this-redirect($this-Auth-redirect());
}
$this-Session-setFlash(__('Invalid username or password, try 
again'));
}
else if ($this-RequestHandler-isAjax())
{
$tmpUser['User']['username'] = 
$this-request-params['username'];
$tmpUser['User']['password'] = 
$this-request-params['password'];
if($this-Auth-login($tmpUser))
{
$this-Session-setFlash('Login Passed');
}
else
{
$this-Session-setFlash('Login Failed');
}
}

if ($this-request-is('ajax')) {
$this-layout = 'ajax';
if ($this-Auth-login()) {
$message = Logged in successfully;
$this-set(array(
'message' = $message,
'_serialize' = array('message')
));
return $this-redirect($this-Auth-redirect());
}
$this-Session-setFlash(__('Invalid username or password, try 
again'));
$message = Invalid username or password, try again;
$this-set(array(
'message' = $message,
'_serialize' = array('message')
));
}
}

Any ideas?

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Can't login with CakePHP's Auth login (Invalid password or username)

2014-03-17 Thread Bruno Messias
Hi guys. 

I'm using cakephp 2.x and can't seem to make Auth-login() work.

app/Controller/AppController.php

class AppController extends Controller {

   // sitema de autentificacao simples 
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
   
public $components = array(
'Session',
'Auth' = array(
'loginAction' = array('controller'='eleitores', 
'action'='login'),
'loginRedirect' = array('controller'='linhas', 
'action'='index'),
'logoutRedirect' = array('controller'='pages', 
'action'='display', 'index'),
'authorize' = array('Controller'),
'authenticate' = array(
'Form' = array(
'userModel' = 'Eleitore',
'scope' = array('Eleitore.id' = 1)
)
),
'authError' = 'Você não possui autorização para acessar esta 
página!'
)
);
 
public function beforeFilter() {
$this-Auth-allow();   
}

...
app/Controller/EleitoresController.php

?php
App::uses('AppController', 'Controller');
/**
 * Eleitores Controller
 *
 * @property Eleitore $Eleitore
 * @property PaginatorComponent $Paginator
 */
class EleitoresController extends AppController {

/**
 * Components
 *
 * @var array
 */
public $components = array('Paginator');


/**
 * index method
 *
 * @return void
 * 
 */
public function beforeFilter() {
parent::beforeFilter();
 // Allow users to register and logout.
  
}

public function login() {
 $this-Auth-userModel = 'GroupUser';
if ($this-request-is('post')) {
 if ($this-Auth-login()) {
return $this-redirect($this-Auth-redirect());
 }
 $this-Session-setFlash(__('Invalid username or password, 
try again'));
}
}

app/View/Eleitores/login.ctp

div class=users form
?php echo $this-Session-flash('auth'); ?
?php echo $this-Form-create('Eleitore'); ?
fieldset
legend
?php echo __('Please enter your username and password'); ?
/legend
?php echo $this-Form-input('username');
echo $this-Form-input('password');
?
/fieldset
?php echo $this-Form-end(__('Login')); ?
/div


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


(CakePHP 2.4.1) Set $useDbConfig in a model, uses the proper DB config, but the login/password used is the one from default datasource

2014-03-05 Thread Daniel Smith
Set $useDbConfig in a model, uses the proper DB config, but the 
login/password used is the one from default datasource

No idea what the issue is, can anyone help?

Thanks

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


plugin for google login and register

2014-02-19 Thread myfinddev
I'm beign looking for a good plugin for google login, but couldn't find a 
proper one. 
got a set of code and i created a component and it worked fine for me but 
now it send an error message saying 
Error fetching OAuth2 access token, message: 'invalid_grant'
This is the url that google call back with 
*googleLogin?code=4/MFlbS6-t6az6Ucy7Z6mJ2qp3u19i.Um 
*when i replace the *?* mark with the */* mark it works fine.
Please help me with this.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Strange IE11 Login Problem

2014-02-05 Thread Sanjeev Divekar
Hi,

My CakePHP App developed in 2.3.6 is working fine in Chrome, Firefox but 
IE11.

I can not login from IE11 from my Desktop. No Auth Message Display. but I 
can login from my Laptop using IE11. any Idea? Anybody know Security 
Settings for IE11

Thanks

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Strange IE11 Login Problem

2014-02-05 Thread Sanjeev Divekar
Solved My Problem.

Configure::write('Session', array(
'defaults' = 'php',
'cookieTimeout' = 0,
'cookie' = 'newNameSESSION',
));

Is the Solution.

http://stackoverflow.com/questions/10256523/cakephp-auth-session-variable-completely-missing-in-chrome-on-some-machines?answertab=active#tab-top

Regards,




On Wednesday, 5 February 2014 21:02:17 UTC+8, Sanjeev Divekar wrote:

 Hi,

 My CakePHP App developed in 2.3.6 is working fine in Chrome, Firefox but 
 IE11.

 I can not login from IE11 from my Desktop. No Auth Message Display. but I 
 can login from my Laptop using IE11. any Idea? Anybody know Security 
 Settings for IE11

 Thanks



-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Cakephp Manual Auth login returns true, but not logged in another page

2013-12-10 Thread Andrew Ponomarev
I found out that $this-Session-Auth array exists and contains correct 
user data, but debug(AuthComponent::user('id')) returns NULL. Why? 

пятница, 21 июня 2013 г., 2:37:44 UTC+4 пользователь Rahul Reddy написал:

 In my cakephp(v 2.3.4) app, I am using the code below to manually login 
 users after they register, as provided in the 
 manualhttp://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#manually-logging-users-in
 .

 if ($this-User-save($this-request-data)) {
 $id = $this-User-id;
 $this-request-data['User'] = 
 array_merge($this-request-data['User'], array('id' = $id));
 if($this-Auth-login($this-request-data['User'])) {
   $this-redirect('/homepage');
 }
 }

 I am getting the $this-Auth-login($this-request-data['User']) response 
 as true and it is getting redirected to the home page. But the user is not 
 logged in homepage (or in any other page). Please help me in fixing this. 
 Thanks in advance.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Starnge redirect from http to https on login

2013-11-22 Thread AD7six
This log does not look to show a redirect changing protocols. it shows, 
what looks like, two parallel/subsequent requests to /users on https and 
http. the last request shown doesn't originate from the request before it 
and has no referer.

If relevant, check what is stored in the session in Auth.redirect; if the 
original request was for http - it's quite possible you're being redirected 
back to http since that's where you were before logging in.

AD

On Thursday, 21 November 2013 22:03:58 UTC+1, dtemes wrote:


 We have just installed a self signed ssl cert on the apache server and 
 doing some tests with our app running over https. The very first issue is 
 that after login we are being redirected to http, and not https, here are 
 some apache logs:

  
 xxx.xxx.com:443http://www.google.com/url?q=http%3A%2F%2Fxxx.xxx.com%3A443sa=Dsntz=1usg=AFQjCNH-cIxUd0HJUR4j8i_f1JqgpSmUuQ192.168.1.3
  - - [21/Nov/2013:12:45:24 -0800] POST /users/login HTTP/1.1 
 302 596 
 https://xxx.xxx.com/users/loginhttps://www.google.com/url?q=https%3A%2F%2Fxxx.xxx.com%2Fusers%2Floginsa=Dsntz=1usg=AFQjCNHLOWqoqK3JEhHkeVMbRjtUgNLOfQ
  
 Moz
 illa/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
 xxx.xxx.com:443http://www.google.com/url?q=http%3A%2F%2Fxxx.xxx.com%3A443sa=Dsntz=1usg=AFQjCNH-cIxUd0HJUR4j8i_f1JqgpSmUuQ192.168.1.3
  - - [21/Nov/2013:12:45:24 -0800] GET /users HTTP/1.1 302 468 
 https://xxx.xxx.com/users/loginhttps://www.google.com/url?q=https%3A%2F%2Fxxx.xxx.com%2Fusers%2Floginsa=Dsntz=1usg=AFQjCNHLOWqoqK3JEhHkeVMbRjtUgNLOfQ
  
 Mozilla/5.
 0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
 xxx.xxx.com:80http://www.google.com/url?q=http%3A%2F%2Fxxx.xxx.com%3A80sa=Dsntz=1usg=AFQjCNHUoTqur5PpY93mdReZ5OabIsz6jA192.168.1.3
  - - [21/Nov/2013:12:45:24 -0800] GET /users HTTP/1.1 302 368 
 - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) G
 ecko/20100101 Firefox/25.0


 This is the auth config:
 $this-Auth-authorize = 'Controller';
 $this-Auth-authenticate = array('Form' = array('fields' = 
 array('username' = 'email', 'password' = 'password')));
 
 $this-Auth-loginRedirect = array('controller' = 'users', 
 'action' = 'index');
 $this-Auth-autoRedirect = false;


 We are currently running cake 2.4.0




-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Starnge redirect from http to https on login

2013-11-22 Thread dtemes
We have found the solution, after sending user credentials the login action 
was redirecting to users/index, that first redirect keeps the https 
protocol, but then in the index action we have some business logic to check 
the type of user and based on that redirecting to the index action of 
controller A or controller B. We have included the logic directly in the 
login action, without redirecting to /users/index, and then the https 
protocol is not lost.

To summarize:

before:

1. user posts login data
2. Redirect to /users/index
3. Based on user role redirect to controllerA/index or controllerB/index, 
here there was an extra redirect to /users/index that was using http and 
not https (???) We don't know where this second redirect to users/index 
comes from.

David

El jueves, 21 de noviembre de 2013 22:03:58 UTC+1, dtemes escribió:


 We have just installed a self signed ssl cert on the apache server and 
 doing some tests with our app running over https. The very first issue is 
 that after login we are being redirected to http, and not https, here are 
 some apache logs:

  
 xxx.xxx.com:443http://www.google.com/url?q=http%3A%2F%2Fxxx.xxx.com%3A443sa=Dsntz=1usg=AFQjCNH-cIxUd0HJUR4j8i_f1JqgpSmUuQ192.168.1.3
  - - [21/Nov/2013:12:45:24 -0800] POST /users/login HTTP/1.1 
 302 596 
 https://xxx.xxx.com/users/loginhttps://www.google.com/url?q=https%3A%2F%2Fxxx.xxx.com%2Fusers%2Floginsa=Dsntz=1usg=AFQjCNHLOWqoqK3JEhHkeVMbRjtUgNLOfQ
  
 Moz
 illa/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
 xxx.xxx.com:443http://www.google.com/url?q=http%3A%2F%2Fxxx.xxx.com%3A443sa=Dsntz=1usg=AFQjCNH-cIxUd0HJUR4j8i_f1JqgpSmUuQ192.168.1.3
  - - [21/Nov/2013:12:45:24 -0800] GET /users HTTP/1.1 302 468 
 https://xxx.xxx.com/users/loginhttps://www.google.com/url?q=https%3A%2F%2Fxxx.xxx.com%2Fusers%2Floginsa=Dsntz=1usg=AFQjCNHLOWqoqK3JEhHkeVMbRjtUgNLOfQ
  
 Mozilla/5.
 0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
 xxx.xxx.com:80http://www.google.com/url?q=http%3A%2F%2Fxxx.xxx.com%3A80sa=Dsntz=1usg=AFQjCNHUoTqur5PpY93mdReZ5OabIsz6jA192.168.1.3
  - - [21/Nov/2013:12:45:24 -0800] GET /users HTTP/1.1 302 368 
 - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) G
 ecko/20100101 Firefox/25.0


 This is the auth config:
 $this-Auth-authorize = 'Controller';
 $this-Auth-authenticate = array('Form' = array('fields' = 
 array('username' = 'email', 'password' = 'password')));
 
 $this-Auth-loginRedirect = array('controller' = 'users', 
 'action' = 'index');
 $this-Auth-autoRedirect = false;


 We are currently running cake 2.4.0




-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Starnge redirect from http to https on login

2013-11-21 Thread Andras Kende
maybe add 

$this-Auth-loginAction = array('controller' = 'users', 'action' = 'login');

Andras Kende
http://www.kede.com


On Nov 21, 2013, at 1:03 PM, dtemes dte...@gmail.com wrote:

 
 We have just installed a self signed ssl cert on the apache server and doing 
 some tests with our app running over https. The very first issue is that 
 after login we are being redirected to http, and not https, here are some 
 apache logs:
 
  xxx.xxx.com:443 192.168.1.3 - - [21/Nov/2013:12:45:24 -0800] POST 
 /users/login HTTP/1.1 302 596 https://xxx.xxx.com/users/login; Moz
 illa/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
 xxx.xxx.com:443 192.168.1.3 - - [21/Nov/2013:12:45:24 -0800] GET /users 
 HTTP/1.1 302 468 https://xxx.xxx.com/users/login; Mozilla/5.
 0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
 xxx.xxx.com:80 192.168.1.3 - - [21/Nov/2013:12:45:24 -0800] GET /users 
 HTTP/1.1 302 368 - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) G
 ecko/20100101 Firefox/25.0
 
 
 This is the auth config:
 $this-Auth-authorize = 'Controller';
 $this-Auth-authenticate = array('Form' = array('fields' = 
 array('username' = 'email', 'password' = 'password')));
 
 $this-Auth-loginRedirect = array('controller' = 'users', 'action' 
 = 'index');
 $this-Auth-autoRedirect = false;
 
 
 We are currently running cake 2.4.0
 
 
 
 -- 
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Starnge redirect from http to https on login

2013-11-21 Thread dtemes

We have just installed a self signed ssl cert on the apache server and 
doing some tests with our app running over https. The very first issue is 
that after login we are being redirected to http, and not https, here are 
some apache logs:

 xxx.xxx.com:443 192.168.1.3 - - [21/Nov/2013:12:45:24 -0800] POST 
/users/login HTTP/1.1 302 596 https://xxx.xxx.com/users/login; Moz
illa/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
xxx.xxx.com:443 192.168.1.3 - - [21/Nov/2013:12:45:24 -0800] GET /users 
HTTP/1.1 302 468 https://xxx.xxx.com/users/login; Mozilla/5.
0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
xxx.xxx.com:80 192.168.1.3 - - [21/Nov/2013:12:45:24 -0800] GET /users 
HTTP/1.1 302 368 - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) G
ecko/20100101 Firefox/25.0


This is the auth config:
$this-Auth-authorize = 'Controller';
$this-Auth-authenticate = array('Form' = array('fields' = 
array('username' = 'email', 'password' = 'password')));

$this-Auth-loginRedirect = array('controller' = 'users', 
'action' = 'index');
$this-Auth-autoRedirect = false;


We are currently running cake 2.4.0


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Login/Auth via webservice / Cake without Database

2013-10-18 Thread Dakota
Luckily for you, CakePHP allows this:
http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#creating-custom-authentication-objects

On Wednesday, 16 October 2013 17:24:45 UTC+2, tool tonic wrote:

 Hello,

 I have to develop an authentication that uses a web service or HTTP 
 request rather than a database. The data will be sent via an HTTP POST 
 request to a server, which responds with a JSON string. This should be 
 evaluated in CakePHP. I would like to use the Auth component of CakePHP, 
 but I do not know how I can solve this problem and would therefore 
 appreciate links to relevant code examples, tutorials, etc. very much!

 Thanks Tooltonix!


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Login/Auth via webservice / Cake without Database

2013-10-17 Thread tool tonic
Hello,

I have to develop an authentication that uses a web service or HTTP request 
rather than a database. The data will be sent via an HTTP POST request to a 
server, which responds with a JSON string. This should be evaluated in 
CakePHP. I would like to use the Auth component of CakePHP, but I do not 
know how I can solve this problem and would therefore appreciate links to 
relevant code examples, tutorials, etc. very much!

Thanks Tooltonix!

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Set database config at login

2013-09-12 Thread Olivier CHEMIN
Hi all,

I have an app wich uses multiple databases. 

One database ('default') for common information, users, companies, etc. The 
login function from the usersController uses this database. 

The rest of the data is stored into another database (let say a 
company_db_name), so after the user has logged in i would like to create 
the connection for this company_db_name and keep it available for the whole 
user session.

I have tried different ways of doing this but it seems i have reached an 
impass... 

Any idea of a nice cakephp way to do this ?

Thanks !

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Set database config at login

2013-09-12 Thread Andras Kende
http://book.cakephp.org/2.0/en/models/model-attributes.html

app/Config/database.php
class DATABASE_CONFIG {
public $default = array(   
………
);
public $company_db_name = array(   
……...
);
}

app/Model/Example.php
class Example extends AppModel {
public $useDbConfig = 'company_db_name';
}

Andras Kende
http://www.kende.com

On Sep 12, 2013, at 1:57 AM, Olivier CHEMIN olivier.che...@gmail.com wrote:

 Hi all,
 
 I have an app wich uses multiple databases. 
 
 One database ('default') for common information, users, companies, etc. The 
 login function from the usersController uses this database. 
 
 The rest of the data is stored into another database (let say a 
 company_db_name), so after the user has logged in i would like to create the 
 connection for this company_db_name and keep it available for the whole user 
 session.
 
 I have tried different ways of doing this but it seems i have reached an 
 impass... 
 
 Any idea of a nice cakephp way to do this ?
 
 Thanks !
 
 -- 
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Ajax Login - Redirect Help

2013-09-10 Thread Mirza Irfan
Your ajax response should send a flag or some value if the session is
expired.
When you receive the Ajax response and finds that value use, javascript to
redirect the page.

//Javascript
window.location()
Google the exact syntax, i am just guiding you.



On Fri, Sep 6, 2013 at 1:51 AM, Advantage+ movepix...@gmail.com wrote:

 I have / working on a site where 90% of the admin area is handled via ajax
 / json.

 ** **

 So I am at the point where I login, destroy the session (on purpose) and
 try to perform an action, which obviously fails but how can I trigger it to
 force the user back to login page, your session has expired please login to
 continue message type setup?

 ** **

 I know about 'ajaxLogin' = '/Elements/users/ajax_login', which is what I
 used before altering all calls to be JSON so no HTML is now getting spit
 back to the view. 

 Just wondering what the easiest, site wide approach would be to direct a
 user to the login page if their session has expired when attempting an ajax
 request.

 ** **

 Any and all ideas welcome,

 ** **

 Thanks

 ** **

 Dave

 --
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Ajax Login - Redirect Help

2013-09-05 Thread Advantage+
I have / working on a site where 90% of the admin area is handled via ajax /
json.

 

So I am at the point where I login, destroy the session (on purpose) and try
to perform an action, which obviously fails but how can I trigger it to
force the user back to login page, your session has expired please login to
continue message type setup?

 

I know about 'ajaxLogin' = '/Elements/users/ajax_login', which is what I
used before altering all calls to be JSON so no HTML is now getting spit
back to the view. 

Just wondering what the easiest, site wide approach would be to direct a
user to the login page if their session has expired when attempting an ajax
request.

 

Any and all ideas welcome,

 

Thanks

 

Dave

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Ajax Login - Redirect Help

2013-09-05 Thread Jeremy Burns : Class Outfit
Don't know if this is the best way of handling this, but this is what I do: 
https://gist.github.com/classoutfit/6459420 It seems to work pretty well.



Jeremy Burns
Class Outfit






Mob: +44 (0) 7973 481949
Tel: +44 (0) 208 123 3822
Skype: jeremy_burns
classoutfit.com
@classoutfit

On 5 Sep 2013, at 21:51, Advantage+ movepix...@gmail.com wrote:

 I have / working on a site where 90% of the admin area is handled via ajax / 
 json.
  
 So I am at the point where I login, destroy the session (on purpose) and try 
 to perform an action, which obviously fails but how can I trigger it to force 
 the user back to login page, your session has expired please login to 
 continue message type setup?
  
 I know about 'ajaxLogin' = '/Elements/users/ajax_login', which is what I 
 used before altering all calls to be JSON so no HTML is now getting spit back 
 to the view.
 Just wondering what the easiest, site wide approach would be to direct a user 
 to the login page if their session has expired when attempting an ajax 
 request.
  
 Any and all ideas welcome,
  
 Thanks
  
 Dave
 
 -- 
 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+unsubscr...@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.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.
inline: mail.png

RE: Ajax Login - Redirect Help

2013-09-05 Thread Advantage+
Thanks for the feedback,

 

What I ended up doing is not optimal but it works.

 

App Controller:

public function beforeFilter() {



if($this-request-is('ajax') (
!$this-AuthUser-status())){

$response = array(

'login' =
true,

'message' =
'You have been logged out. Please login to continue.');



 
$this-_ajaxResponse($response);

 

}

}

 

And in my js since most run off the same function for returning data:

 

Snip:

success: function(r){

forceLogin(r);

 

so if the forceLogin === true as determined in the JSON response it simply
redirects to login

 

function forceLogin(r) {

if(r.login  (r.login === true)){

window.location.href=/login; 

}

};

 

Still open to better ideas / methods but for now it works so that's all that
matters J

 

Dave

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of Jeremy Burns : Class Outfit
Sent: Friday, September 06, 2013 1:35 AM
To: cake-php@googlegroups.com
Subject: Re: Ajax Login - Redirect Help

 

Don't know if this is the best way of handling this, but this is what I do:
https://gist.github.com/classoutfit/6459420 It seems to work pretty well.

 

 


Jeremy Burns

Class Outfit

 







Mob: +44 (0) 7973 481949

Tel: +44 (0) 208 123 3822
Skype: jeremy_burns
classoutfit.com http://www.classoutfit.com 

@classoutfit https://twitter.com/classoutfit 

 

On 5 Sep 2013, at 21:51, Advantage+ movepix...@gmail.com wrote:





I have / working on a site where 90% of the admin area is handled via ajax /
json.

 

So I am at the point where I login, destroy the session (on purpose) and try
to perform an action, which obviously fails but how can I trigger it to
force the user back to login page, your session has expired please login to
continue message type setup?

 

I know about 'ajaxLogin' = '/Elements/users/ajax_login', which is what I
used before altering all calls to be JSON so no HTML is now getting spit
back to the view.

Just wondering what the easiest, site wide approach would be to direct a
user to the login page if their session has expired when attempting an ajax
request.

 

Any and all ideas welcome,

 

Thanks

 

Dave

 

-- 
Like Us on FaceBook  https://www.facebook.com/CakePHP
https://www.facebook.com/CakePHP
Find us on Twitter  http://twitter.com/CakePHP 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  mailto:cake-php+unsubscr...@googlegroups.com
cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to  mailto:cake-php@googlegroups.com
cake-php@googlegroups.com.
Visit this group at  http://groups.google.com/group/cake-php
http://groups.google.com/group/cake-php.
For more options, visit  https://groups.google.com/groups/opt_out
https://groups.google.com/groups/opt_out.

 

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
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+unsubscr...@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.
For more options, visit https://groups.google.com/groups/opt_out.
image002.png

  1   2   3   4   5   6   7   8   9   10   >