// Register validation $app->post('/register_check', function (Request $request) use($app) { $data = $request->request->all(); $user = new User(); $user->setUsername($data["_username"]); $salt = substr(md5(time()), 0, 23); $user->setSalt($salt); $plainPassword = $data["_password"]; $encoder = $app['security.encoder.digest']; $password = $encoder->encodePassword($plainPassword, $user->getSalt()); $user->setPassword($password); $user->setRole("ROLE_USER"); $user->setMail($data["_mail"]); $user->setTelephone($data["_tel"]); $user->setVille($data["_ville"]); $user->setAdresse($data["_adresse"]); $userDao = new UserDAO($app['db']); $userDao->save($user); return $app->redirect('/login'); })->bind('register_check'); $app->get('/produit', function (Request $request) use($app) { $produitDAO = new produitDAO($app['db']); $mesProduits = $produitDAO->findAll(); if (!$app['session']->has('panier')) { return $app['twig']->render('produit.html.twig', array('error' => $app['security.last_error']($request), 'last_username' => $app['session']->get('_security.last_username'), 'ProduitsALL' => $mesProduits)); } else { return $app['twig']->render('produit.html.twig', array('error' => $app['security.last_error']($request), 'last_username' => $app['session']->get('_security.last_username'), 'ProduitsALL' => $mesProduits)); } })->bind('produit'); $app->get('/panier', function (Request $request) use($app) { if (!$app['session']->has('panier')) {
/** * Creates a User object based on a DB row. * * @param array $row The DB row containing User data. * @return \MicroCMS\Domain\User */ protected function buildDomainObject($row) { $user = new User(); $user->setId($row['usr_id']); $user->setUsername($row['usr_name']); $user->setPassword($row['usr_password']); $user->setSalt($row['usr_salt']); $user->setRole($row['usr_role']); $user->setMail($row['usr_mail']); $user->setTelephone($row['usr_tel']); $user->setAdresse($row['usr_adr']); $user->setVille($row['usr_ville']); return $user; }