/var/www/vhosts/ihelp.ro/_OLD/src/Controller
NameSizeModeActions
Component/-0755rm
AppController.php23300644editdlrm
CauseImagesController.php34080644editdlrm
CausesController.php21720644editdlrm
ErrorController.php17680644editdlrm
PagesController.php6160644editdlrm
ProfilesController.php43200644editdlrm
UsersController.php56490644editdlrm
Edit: /var/www/vhosts/ihelp.ro/_OLD/src/Controller/UsersController.php (5649B)
Authentication->addUnauthenticatedActions(['login', 'add']); } /** * Login method * * */ public function login() { $this->Authorization->skipAuthorization(); $this->request->allowMethod(['get', 'post']); $result = $this->Authentication->getResult(); // regardless of POST or GET, redirect if user is logged in if ($result->isValid()) { // redirect to /articles after login success $redirect = $this->request->getQuery('redirect', [ 'controller' => 'Profiles', 'action' => 'view', ]); return $this->redirect($redirect); } // display error if user submitted and authentication failed if ($this->request->is('post') && !$result->isValid()) { $this->Flash->error(__('Invalid email or password')); } } /** * Logout method * * */ public function logout() { $this->Authorization->skipAuthorization(); $result = $this->Authentication->getResult(); // regardless of POST or GET, redirect if user is logged in if ($result->isValid()) { $this->Authentication->logout(); $this->Flash->success(__('LogOut')); return $this->redirect(['controller' => 'Pages', 'action' => 'home']); } } /** * Dashboard method * * @return \Cake\Http\Response|null|void Renders view */ public function listUsers() { $this->Authorization->skipAuthorization(); $this->paginate = [ 'contain' => ['Roles'], ]; $users = $this->paginate($this->Users); $this->set(compact('users')); } /** * View method * * @param string|null $uuid User uuid. * @return \Cake\Http\Response|null|void Renders view * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function view() { $this->Authorization->skipAuthorization(); $user = $this->Users->get($this->userAuth->id, [ 'contain' => ['Roles', 'Causes', 'Messages', 'Orders', 'PaymentLogs', 'ProductFavorites', 'Products', 'Profiles'], ]); $this->set(compact('user')); } /** * Add method * * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add() { $this->Authorization->skipAuthorization(); $user = $this->Users->newEmptyEntity(); if ($this->request->is('post')) { $user = $this->Users->patchEntity($user, $this->request->getData()); if ($this->Users->save($user, ['associated' => ['Profiles']])) { $this->Flash->success(__('The user has been saved.')); return $this->redirect(['controller' => 'Profiles', 'action' => 'view']); } else { //debug($user->getErrors()); } $this->Flash->error(__('The user could not be saved. Please, try again.')); } $this->set(compact('user')); } /** * Edit method * * @param string|null $id User id. * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function edit($uuid = null) { $this->Authorization->skipAuthorization(); $user = $this->Users->find()->where(['id' => $this->userAuth->id])->first(); $id = $user->id; $user = $this->Users->get($id, [ 'contain' => [], ]); if ($this->request->is(['patch', 'post', 'put'])) { $user = $this->Users->patchEntity($user, $this->request->getData()); if ($this->Users->save($user)) { $this->Flash->success(__('The user has been saved.')); return $this->redirect(['controller' => 'Profiles', 'action' => 'view']); } $this->Flash->error(__('The user could not be saved. Please, try again.')); } $this->set(compact('user')); } /** * Delete method * * @param string|null $id User id. * @return \Cake\Http\Response|null|void Redirects to index. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function delete($uuid = null) { $this->Authorization->skipAuthorization(); $user = $this->Users->find()->where(['uuid' => $uuid])->first(); $id = $user->id; $this->request->allowMethod(['post', 'delete']); $user = $this->Users->get($id); if ($this->Users->delete($user)) { $this->Flash->success(__('The user has been deleted.')); } else { $this->Flash->error(__('The user could not be deleted. Please, try again.')); } return $this->redirect(['action' => 'dashboard']); } }