Last active
December 10, 2015 20:58
-
-
Save chewbakartik/4491756 to your computer and use it in GitHub Desktop.
Security Configuration for Typo3 Flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Settings.yaml: | |
TYPO3: | |
Flow: | |
security: | |
enable: TRUE | |
authentication: | |
authenticationStrategy: oneToken | |
providers: | |
DefaultProvider: | |
provider: PersistedUsernamePasswordProvider | |
login form: | |
<f:form action="authenticate" method="post" name="loginform"> | |
<label>User:</label><f:form.textfield name="TYPO3[Flow][Security][Authentication][Token][UsernamePassword][username]" /><br /> | |
<label>Password:</label><f:form.password name="TYPO3[Flow][Security][Authentication][Token][UsernamePassword][password]" /><br /> | |
<f:form.submit value="Login" /> | |
</f:form> | |
authenticate action: | |
/** | |
* @throws \TYPO3\Flow\Security\Exception\AuthenticationRequiredException | |
* @return void | |
*/ | |
public function authenticateAction() { | |
try { | |
$this->authenticationManager->authenticate(); | |
$this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Successfully logged in.')); | |
$this->redirect('index', 'Login'); | |
} catch (\TYPO3\Flow\Security\Exception\AuthenticationRequiredException $exception) { | |
$this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Wrong username or password.')); | |
$this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error($exception->getMessage())); | |
throw $exception; | |
} | |
} | |
create action: | |
/** | |
* save the registration | |
* @param string $name | |
* @param string $pass | |
* @param string $pass2 | |
*/ | |
public function createAction($name, $pass, $pass2) { | |
$defaultRole = 'Visitor'; | |
if($name == '' || strlen($name) < 3) { | |
$this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Username too short or empty')); | |
$this->redirect('register', 'Login'); | |
} else if($pass == '' || $pass != $pass2) { | |
$this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Password too short or does not match')); | |
$this->redirect('register', 'Login'); | |
} else { | |
// create a account with password an add it to the accountRepository | |
$account = $this->accountFactory->createAccountWithPassword($name, $pass, array($defaultRole)); | |
$this->accountRepository->add($account); | |
// add a message and redirect to the login form | |
$this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Account created. Please login.')); | |
$this->redirect('index'); | |
} | |
// 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