forked from TYPO3-Headless/headless
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task/felogin adjustments (TYPO3-Headless#481)
* [TASK] Add felogin adjustments, fix recovery url, add login data to initial data, fix fieeld name
- Loading branch information
1 parent
2147ca8
commit 0cb1e1d
Showing
11 changed files
with
170 additions
and
29 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the "headless" Extension for TYPO3 CMS. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FriendsOfTYPO3\Headless\XClass\Controller; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use TYPO3\CMS\Extbase\Http\ForwardResponse; | ||
use TYPO3\CMS\FrontendLogin\Event\BeforeRedirectEvent; | ||
use TYPO3\CMS\FrontendLogin\Event\LoginConfirmedEvent; | ||
use TYPO3\CMS\FrontendLogin\Event\LoginErrorOccurredEvent; | ||
use TYPO3\CMS\FrontendLogin\Event\LogoutConfirmedEvent; | ||
use TYPO3\CMS\FrontendLogin\Event\ModifyLoginFormViewEvent; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class LoginController extends \TYPO3\CMS\FrontendLogin\Controller\LoginController | ||
{ | ||
/** | ||
* Show login form | ||
*/ | ||
public function loginAction(): ResponseInterface | ||
{ | ||
$status = 'success'; | ||
|
||
if ($this->isLogoutSuccessful()) { | ||
$this->eventDispatcher->dispatch(new LogoutConfirmedEvent($this, $this->view)); | ||
} elseif ($this->hasLoginErrorOccurred()) { | ||
$status = 'failure'; | ||
$this->eventDispatcher->dispatch(new LoginErrorOccurredEvent()); | ||
} | ||
|
||
if (($forwardResponse = $this->handleLoginForwards()) !== null) { | ||
return $forwardResponse; | ||
} | ||
|
||
if ($this->redirectUrl !== '') { | ||
$this->eventDispatcher->dispatch(new BeforeRedirectEvent($this->loginType, $this->redirectUrl)); | ||
$data = [ | ||
'redirectUrl' => $this->redirectUrl, | ||
'statusCode' => 301 | ||
]; | ||
return $this->responseFactory->createResponse()->withHeader('Content-Type', 'application/json; charset=utf-8') | ||
->withBody($this->streamFactory->createStream(json_encode($data))); | ||
} | ||
$this->eventDispatcher->dispatch(new ModifyLoginFormViewEvent($this->view)); | ||
|
||
$this->view->assignMultiple( | ||
[ | ||
'status' => $status, | ||
'cookieWarning' => $this->showCookieWarning, | ||
'messageKey' => $this->getStatusMessageKey(), | ||
'storagePid' => implode(',', $this->getStorageFolders()), | ||
'permaloginStatus' => $this->getPermaloginStatus(), | ||
'redirectURL' => $this->redirectHandler->getLoginFormRedirectUrl($this->configuration, $this->isRedirectDisabled()), | ||
'redirectReferrer' => $this->request->hasArgument('redirectReferrer') ? (string)$this->request->getArgument('redirectReferrer') : '', | ||
'referer' => $this->requestHandler->getPropertyFromGetAndPost('referer'), | ||
'noRedirect' => $this->isRedirectDisabled(), | ||
] | ||
); | ||
|
||
return $this->jsonResponse(); | ||
} | ||
|
||
/** | ||
* User overview for logged in users | ||
* | ||
* @param bool $showLoginMessage | ||
* @return ResponseInterface | ||
*/ | ||
public function overviewAction(bool $showLoginMessage = false): ResponseInterface | ||
{ | ||
$status = 'success'; | ||
|
||
if (!$this->userAspect->isLoggedIn()) { | ||
return new ForwardResponse('login'); | ||
} | ||
|
||
$this->eventDispatcher->dispatch(new LoginConfirmedEvent($this, $this->view)); | ||
|
||
if ($this->redirectUrl !== '') { | ||
$this->eventDispatcher->dispatch(new BeforeRedirectEvent($this->loginType, $this->redirectUrl)); | ||
$data = [ | ||
'redirectUrl' => $this->redirectUrl, | ||
'statusCode' => 301, | ||
'status' => 'success' | ||
]; | ||
return $this->responseFactory->createResponse()->withHeader('Content-Type', 'application/json; charset=utf-8') | ||
->withBody($this->streamFactory->createStream(json_encode($data))); | ||
} | ||
|
||
$this->view->assignMultiple( | ||
[ | ||
'status' => $status, | ||
'cookieWarning' => $this->showCookieWarning, | ||
'user' => $this->userService->getFeUserData(), | ||
'showLoginMessage' => $showLoginMessage, | ||
] | ||
); | ||
|
||
return $this->htmlResponse(); | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<f:spaceless> | ||
[ | ||
<f:format.raw> | ||
<f:format.json value="{ | ||
identifier: 'required', | ||
message: 'This field is mandatory.' | ||
}"/> | ||
</f:format.raw> | ||
] | ||
</f:spaceless> |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<f:spaceless> | ||
<f:format.raw> | ||
<f:format.json value="{ | ||
status: '{status}', | ||
login: '{user.username}', | ||
message: '{f:translate(key:\'success_header\')}' | ||
}"/> | ||
</f:format.raw> | ||
</f:spaceless> |
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
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