Guest User

login

a guest
Apr 18th, 2013
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.83 KB | None | 0 0
  1. ######LOGINCONTROLLER##############
  2. class LoginController extends \TYPO3\Flow\Mvc\Controller\ActionController {
  3.  
  4.     /**
  5.      * @Flow\Inject
  6.      * @var \TYPO3\Flow\Security\Authentication\AuthenticationManagerInterface
  7.      */
  8.     protected $authenticationManager;
  9.  
  10.     /**
  11.      * @Flow\Inject
  12.      * @var \TYPO3\Flow\Security\AccountRepository
  13.      */
  14.     protected $accountRepository;
  15.  
  16.      /**
  17.      * @Flow\Inject
  18.      * @var \TYPO3\Flow\Security\AccountFactory
  19.      */
  20.     protected $accountFactory;
  21.  
  22. .....
  23.   /**
  24.      * index action, does only display the form
  25.      */
  26.     public function indexAction() {
  27.     // access account informations
  28.      $account = $this->securityContext->getAccount();
  29.     }
  30.  /**
  31.  
  32.      * authenticate a User, check if his account or community is active, set logindate
  33.      * @throws \TYPO3\Flow\Security\Exception\AuthenticationRequiredException
  34.      * @return void
  35.      */
  36.     public function authenticateAction() {
  37.         try {
  38.             $this->authenticationManager->authenticate();
  39.         $account = $this->securityContext->getAccount();
  40.  
  41.  
  42.          $this->redirect('index', 'Objekt',null,$my_config);
  43.  
  44.         } catch (\TYPO3\Flow\Security\Exception\AuthenticationRequiredException $exception) {
  45.             $this->addFlashMessage('Wrong password or username!', '');
  46.             throw $exception;
  47.  
  48.         }
  49.   }
  50. ###################################################packages's Settings.yaml #####################
  51. TYPO3:
  52.   Flow:
  53.     i18n:
  54.       defaultLocale: de
  55.     security:
  56.       authentication:
  57.         authenticationStrategy: oneToken
  58.         providers:
  59.           DefaultProvider:
  60.             provider: 'PersistedUsernamePasswordProvider'
  61.             entryPoint: 'WebRedirect'
  62.             entryPointOptions:
  63.               uri: 'index.php/MY.Package/login'
  64. ###########################################TEMPLATE ################################################
  65. ..
  66.  <f:security.ifHasRole role="Anonymous">
  67.         <f:then>
  68.              <f:form action="authenticate" method="post" name="loginform" class="well form-horizontal f3-custom-login-form">
  69.                <legend>Administrations</legend>
  70.                 <label for="login" class="control-label">Name:</label>
  71.                 <div class="controls">
  72.                     <f:form.textfield name="__authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][username]" id="login"/><br />
  73.                 </div>
  74.                 <label for="pw" class="control-label">Password:</label>
  75.                 <div class="controls">
  76.                     <f:form.password name="__authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][password]" id="pw"/><br /><br />
  77.                 </div>
  78.                 <div class="controls">
  79.                     <f:form.submit value="Login" class="btn" />
  80.                 </div>
  81.             </f:form>
  82.         </f:then>
  83.     </f:security.ifHasRole>
  84. ..
Advertisement
Add Comment
Please, Sign In to add comment