Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######LOGINCONTROLLER##############
- class LoginController extends \TYPO3\Flow\Mvc\Controller\ActionController {
- /**
- * @Flow\Inject
- * @var \TYPO3\Flow\Security\Authentication\AuthenticationManagerInterface
- */
- protected $authenticationManager;
- /**
- * @Flow\Inject
- * @var \TYPO3\Flow\Security\AccountRepository
- */
- protected $accountRepository;
- /**
- * @Flow\Inject
- * @var \TYPO3\Flow\Security\AccountFactory
- */
- protected $accountFactory;
- .....
- /**
- * index action, does only display the form
- */
- public function indexAction() {
- // access account informations
- $account = $this->securityContext->getAccount();
- }
- /**
- * authenticate a User, check if his account or community is active, set logindate
- * @throws \TYPO3\Flow\Security\Exception\AuthenticationRequiredException
- * @return void
- */
- public function authenticateAction() {
- try {
- $this->authenticationManager->authenticate();
- $account = $this->securityContext->getAccount();
- $this->redirect('index', 'Objekt',null,$my_config);
- } catch (\TYPO3\Flow\Security\Exception\AuthenticationRequiredException $exception) {
- $this->addFlashMessage('Wrong password or username!', '');
- throw $exception;
- }
- }
- ###################################################packages's Settings.yaml #####################
- TYPO3:
- Flow:
- i18n:
- defaultLocale: de
- security:
- authentication:
- authenticationStrategy: oneToken
- providers:
- DefaultProvider:
- provider: 'PersistedUsernamePasswordProvider'
- entryPoint: 'WebRedirect'
- entryPointOptions:
- uri: 'index.php/MY.Package/login'
- ###########################################TEMPLATE ################################################
- ..
- <f:security.ifHasRole role="Anonymous">
- <f:then>
- <f:form action="authenticate" method="post" name="loginform" class="well form-horizontal f3-custom-login-form">
- <legend>Administrations</legend>
- <label for="login" class="control-label">Name:</label>
- <div class="controls">
- <f:form.textfield name="__authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][username]" id="login"/><br />
- </div>
- <label for="pw" class="control-label">Password:</label>
- <div class="controls">
- <f:form.password name="__authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][password]" id="pw"/><br /><br />
- </div>
- <div class="controls">
- <f:form.submit value="Login" class="btn" />
- </div>
- </f:form>
- </f:then>
- </f:security.ifHasRole>
- ..
Advertisement
Add Comment
Please, Sign In to add comment