/**
  * Set new avatar
  *
  * @return mixed
  */
 public function setAvatarAction()
 {
     if ($this->getRequest()->isPost()) {
         $user = new User();
         $user->user_avatar = $this->getRequest()->file('avatarupload');
         $validator = new Validator($user);
         if ($validator->isAvatarValid()) {
             $user->avatarSave();
         } else {
             $error = $validator->getErrors();
         }
     }
     return true;
 }
 /**
  * Save avatar
  *
  * @return \Framework\Response\Response
  */
 public function avatarAction()
 {
     if ($this->getRequest()->isPost()) {
         $user = new User();
         $user->user_avatar = $this->getRequest()->file('avatarupload');
         $validator = new Validator($user);
         if ($validator->isAvatarValid()) {
             $user->avatarSave();
         } else {
             $error = $validator->getErrors();
         }
     }
     $profile = User::findInfo();
     return $this->render('profile.html', ['info' => $profile, 'errors' => isset($error) ? $error : null]);
 }
 /**
  * Sign up new User
  *
  * @return \Framework\Response\Response
  */
 public function signupAction()
 {
     if (ServiceContainer::get('security')->isAuthenticated()) {
         $redirect = new ResponseRedirect($this->generateRoute('performance_home'));
         $redirect->send();
     }
     $errors = array();
     if ($this->getRequest()->isPost() == 'POST') {
         try {
             $user = new User();
             $user->name = $this->getRequest()->post('name');
             $user->email = $this->getRequest()->post('email');
             $user->password = md5($this->getRequest()->post('password'));
             $user->user_role = 'ROLE_USER';
             $user->save();
             return $this->redirect($this->generateRoute('security_signin'));
         } catch (\Exception $e) {
             $errors = array($e->getMessage());
         }
     }
     return $this->render('signup.html', array('errors' => $errors));
 }
Пример #4
0
 public function loginAction()
 {
     $auth = $this->getAuth();
     if ($auth->hasIdentity()) {
         return $this->redirect()->toRoute('todo');
     }
     $form = new LoginForm();
     $form->get('submit')->setValue('Login');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $authAdapter = new AuthAdapter($this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter'), 'user', 'email', 'password', 'MD5(?)');
             $authAdapter->setIdentity($data['email'])->setCredential($data['password']);
             $auth->authenticate($authAdapter);
             return $this->redirect()->toRoute('todo');
         } else {
         }
     }
     return array('form' => $form);
 }