I am developing using CakePHP 2.5.6, and I am having an issue with users getting access to other users' info.
When a user (let's say User1) registers and fills out some optional fields in their profile, and from the same IP another user (User2) registers/logs in, whilst not having filled out the optional info, then User2 will see the User1's optional info (fields that are left empty). It doesn't seem to make a difference if User1 clicks logout or not. I am storing some primary cross-site information in the session, like user's name, email, profile image, etc.
In core.php I have very basic settings, like
Configure::write('Session', array(
'defaults' => 'cake',
'checkAgent' => true,
));
Configure::write('Security.level', 'low');
Logins go through UsersController.php, which has the separate view like
public function login() {
// Destroy old users' data just in case
$this->Session->destroy();
$this->Cookie->delete('rememberMe');
//if already logged-in, redirect
if (AuthComponent::user('id')) {
if (isset($this->request->data['User']['rememberMe'])) {
if ($this->request->data['User']['rememberMe'] == "on") {
unset($this->request->data['User']['rememberMe']);
$cookieTime = "12 months";
$this->request->data['User']['password'] = Security::hash($this->request->data['User']['password']);
$this->Cookie->write('rememberMe', $this->request->data['User'], true, $cookieTime);
}
}
$id = AuthComponent::user('id');
$this->User->id = $id;
$this->Session->write('Config.language', $this->User->field("language"));
Configure::write('Config.language', $this->User->field("language"));
$this->redirect(array('controller' => 'dashboard', 'action' => 'index'));
}
// if we get the post information, try to authenticate
else if ($this->request->is('post')) {
$user = $this->User->findByUsername($this->request->data['User']['username']);
$this->Session->write('Config.language', $user['User']['language']);
Configure::write('Config.language', $user['User']['language']);
if ($user['User']['connected'] == null) {
$this->Session->setFlash(__('Unverified user, please check your email and verify your account'), 'flash_error');
} else {
if ($user['User']['tries'] <= 7 && $this->Auth->login()) {
if (isset($this->request->data['User']['rememberMe']) && $this->request->data['User']['rememberMe'] == "on") {
unset($this->request->data['User']['rememberMe']);
$cookieTime = "12 months";
$this->request->data['User']['password'] = Security::hash($this->request->data['User']['password']);
$this->Cookie->write('rememberMe', $this->request->data['User'], true, $cookieTime);
}
$this->redirect($this->Auth->redirectUrl());
} else {
$this->Session->setFlash(__('Invalid username or password'), 'flash_error');
}
}
}
and logouts are supposed to just destroy everything
public function logout() {
$this->Session->destroy();
$this->Cookie->delete('rememberMe');
$this->redirect($this->Auth->logout());
}
Now, my question is - is it something that I can change/fix in CakePHP, or does it have to be changed in php.ini or server settings? What could be causing it?
Thank you for any help and tips!