function resendVerifyEmail(Request $request, Application $app) { $repo = new UserAccountVerifyEmailRepository(); $date = $repo->getLastSentForUserAccount($app['currentUser']); if ($date && $date->getTimestamp() > \TimeSource::time() - $app['config']->userAccountVerificationSecondsBetweenAllowedSends) { $app['flashmessages']->addMessage("Sorry, but an email was sent too recently. Please try again later."); } else { $verifyEmail = $repo->create($app['currentUser']); $verifyEmail->sendEmail($app, $app['currentUser']); $app['flashmessages']->addMessage("Verification email resent."); } return $app->redirect("/me/"); }
function show($id, Request $request, Application $app) { $this->build($id, $request, $app); $form = $app['form.factory']->create(new ActionForm()); if ('POST' == $request->getMethod()) { $form->bind($request); if ($form->isValid()) { $data = $form->getData(); $action = new ActionParser($data['action']); $uar = new UserAccountRepository(); if ($action->getCommand() == 'editor' && $action->getParam(0) == 'yes') { $this->parameters['user']->setIsEditor(true); $uar->edit($this->parameters['user']); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } else { if ($action->getCommand() == 'editor' && $action->getParam(0) == 'no') { $this->parameters['user']->setIsEditor(false); $uar->edit($this->parameters['user']); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } else { if ($action->getCommand() == 'sysadmin' && $action->getParam(0) == 'yes') { $this->parameters['user']->setIsSystemAdmin(true); $uar->edit($this->parameters['user']); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } else { if ($action->getCommand() == 'sysadmin' && $action->getParam(0) == 'no') { $this->parameters['user']->setIsSystemAdmin(false); $uar->edit($this->parameters['user']); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } else { if ($action->getCommand() == 'verifyemail') { $uar->verifyEmail($this->parameters['user']); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } else { if ($action->getCommand() == 'resendverificationemail' && !$this->parameters['user']->getIsEmailVerified()) { $repo = new UserAccountVerifyEmailRepository(); $verify = $repo->create($this->parameters['user']); $verify->sendEmail($app, $this->parameters['user']); $app['flashmessages']->addMessage('Sent'); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } else { if ($action->getCommand() == 'close') { $uar->systemAdminShuts($this->parameters['user'], $app['currentUser'], $action->getParam(0)); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } else { if ($action->getCommand() == 'open') { $uar->systemAdminOpens($this->parameters['user'], $app['currentUser']); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } else { if ($action->getCommand() == 'email' && filter_var($action->getParam(0), FILTER_VALIDATE_EMAIL)) { $this->parameters['user']->setEmail($action->getParam(0)); $uar->editEmail($this->parameters['user']); return $app->redirect('/sysadmin/user/' . $this->parameters['user']->getId()); } } } } } } } } } } } $this->parameters['form'] = $form->createView(); return $app['twig']->render('sysadmin/user/show.html.twig', $this->parameters); }
function register(Request $request, Application $app) { global $CONFIG; if (!$app['config']->allowNewUsersToRegister) { return $app['twig']->render('index/user/register.notallowed.html.twig', array()); } $this->processThingsToDoAfterGetUser($request, $app); $userRepository = new UserAccountRepository(); $form = $app['form.factory']->create(new SignUpUserForm()); if ('POST' == $request->getMethod()) { $form->bind($request); $data = $form->getData(); if (is_array($CONFIG->userNameReserved) && in_array($data['username'], $CONFIG->userNameReserved)) { $form->addError(new FormError('That user name is already taken')); } $userExistingUserName = $userRepository->loadByUserName($data['username']); if ($userExistingUserName) { $form->addError(new FormError('That user name is already taken')); } $userExistingEmail = $userRepository->loadByEmail($data['email']); if ($userExistingEmail) { $form->addError(new FormError('That email address already has an account')); } if ($form->isValid()) { $user = new UserAccountModel(); $user->setEmail($data['email']); $user->setUsername($data['username']); $user->setPassword($data['password1']); $userRepository->create($user); $repo = new UserAccountVerifyEmailRepository(); $userVerify = $repo->create($user); $userVerify->sendEmail($app, $user); userLogIn($user); $this->actionThingsToDoAfterGetUser($app, $user); return $app->redirect("/"); } } $this->parameters['form'] = $form->createView(); return $app['twig']->render('index/user/register.html.twig', $this->parameters); }