/** * Try user to log in. * * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function loginAction(Request $request) { $data = $request->request->all(); $user = new User(); $user->load($data['email'], 'email'); if (!empty($user->getId()) && $user->getPassword() == md5($data['pass'])) { $request->getSession()->set('userId', $user->getId()); $request->getSession()->set('userName', $user->getName()); $request->getSession()->set('userSName', $user->getSecondName()); $request->getSession()->set('userRole', $user->getRoleId()); return $this->redirectToRoute('home'); } $request->getSession()->set('message', 'User with current login and password not found.'); return $this->redirectToRoute('lance_authorization'); }