Skip to content

Instantly share code, notes, and snippets.

@Allisone
Created March 14, 2012 10:44
Show Gist options
  • Save Allisone/2035697 to your computer and use it in GitHub Desktop.
Save Allisone/2035697 to your computer and use it in GitHub Desktop.
Create Account
<f:flashMessages />
<f:form action="create" controller="Login" method="post" name="createform">
<div><label>Email:</label><f:form.textfield name="email" /></div>
<div><label>Password:</label><f:form.textfield name="pw" /></div>
<div><label>Repeat Password:</label><f:form.textfield name="pwr" /></div>
<div><label>Username:</label><f:form.textfield name="uname" /></div>
<f:form.submit value="Register and Login" />
</f:form>
<?php
namespace Me\My\Controller;
/* *
* This script belongs to the FLOW3 package "Me.My". *
* *
* */
use TYPO3\FLOW3\Annotations as FLOW3;
/**
* Login controller for the Me.My package
*
* @FLOW3\Scope("singleton")
*/
class LoginController extends \TYPO3\FLOW3\MVC\Controller\ActionController {
/**
* save the registration
* @param string $email email
* @param string $pw password
* @param string $pwr password repeat
* @param string $uname username
*/
public function createAction($email,$pw,$pwr,$uname) {
$defaultRole = 'User';
if($email == '' || strlen($email) < 3) {
$this->addFlashMessage('Username too short or empty');
$this->redirect('register', 'Login');
} else if($pw == '' || $pw != $pwr) {
$this->addFlashMessage('Password too short or does not match');
$this->redirect('register', 'Login');
} else {
$account = $this->accountFactory->createAccountWithPassword($email,$pw, array($defaultRole));
$account->setAuthenticationProviderName('DefaultProvider');
$this->accountRepository->add($account);
// add a message and redirect to the login form
$this->addFlashMessage('Account created. Please login.');
$this->redirect('index');
// TODO: create and add party
}
// redirect to the login form
$this->redirect('index', 'Login');
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment