diff --git a/lib/Alchemy/Phrasea/Application/Root.php b/lib/Alchemy/Phrasea/Application/Root.php
index 88a89b201f..8169b598cb 100644
--- a/lib/Alchemy/Phrasea/Application/Root.php
+++ b/lib/Alchemy/Phrasea/Application/Root.php
@@ -57,7 +57,6 @@ return call_user_func(function() {
$app->mount('/feeds/', new RSSFeeds());
$app->mount('/account/', new Account());
- $app->mount('/login/authenticate/', new AuthenticateController());
$app->mount('/login/', new Login());
$app->mount('/developers/', new Developers());
diff --git a/lib/Alchemy/Phrasea/Controller/Login/Authenticate.php b/lib/Alchemy/Phrasea/Controller/Login/Authenticate.php
deleted file mode 100644
index af8cb7a7b8..0000000000
--- a/lib/Alchemy/Phrasea/Controller/Login/Authenticate.php
+++ /dev/null
@@ -1,113 +0,0 @@
-post('/', __CLASS__ . '::authenticate')
- ->before(function() use ($app) {
- return $app['phraseanet.core']['Firewall']->requireNotAuthenticated($app);
- });
-
- return $controllers;
- }
-
- public function authenticate(Application $app, Request $request)
- {
- /* @var $Core \Alchemy\Phrasea\Core */
- $Core = $app['phraseanet.core'];
-
- $appbox = \appbox::get_instance($Core);
- $session = $appbox->get_session();
- $registry = $appbox->get_registry();
-
- if ($registry->get('GV_captchas')
- && trim($registry->get('GV_captcha_private_key')) !== ''
- && trim($registry->get('GV_captcha_public_key')) !== '')
- include($registry->get('GV_RootPath') . 'lib/vendor/recaptcha/recaptchalib.php');
-
- $is_guest = false;
-
- if (null !== $request->get('nolog') && \phrasea::guest_allowed()) {
- $is_guest = true;
- }
-
- if ((null !== $request->get('login') && null !== $request->get('pwd')) || $is_guest) {
-
- /**
- * @todo dispatch an event that can be used to tweak the authentication
- * (LDAP....)
- */
- // $app['dispatcher']->dispatch();
-
- try {
- if ($is_guest) {
- $auth = new \Session_Authentication_Guest($appbox);
- } else {
- $captcha = false;
-
- if ($registry->get('GV_captchas')
- && trim($registry->get('GV_captcha_private_key')) !== ''
- && trim($registry->get('GV_captcha_public_key')) !== ''
- && ! is_null($request->get("recaptcha_challenge_field")
- && ! is_null($request->get("recaptcha_response_field")))) {
- $checkCaptcha = recaptcha_check_answer($registry->get('GV_captcha_private_key'), $_SERVER["REMOTE_ADDR"], $request->get("recaptcha_challenge_field"), $request->get("recaptcha_response_field"));
-
- if ($checkCaptcha->is_valid) {
- $captcha = true;
- }
- }
-
- $auth = new \Session_Authentication_Native($appbox, $request->get('login'), $request->get('pwd'));
- $auth->set_captcha_challenge($captcha);
- }
- $session->authenticate($auth);
- } catch (\Exception_Session_StorageClosed $e) {
- return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=session");
- } catch (\Exception_Session_RequireCaptcha $e) {
- return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=captcha");
- } catch (\Exception_Unauthorized $e) {
- return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=auth");
- } catch (\Exception_Session_MailLocked $e) {
- return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=mail-not-confirmed&usr=" . $e->get_usr_id());
- } catch (\Exception_Session_WrongToken $e) {
- return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=token");
- } catch (\Exception_InternalServerError $e) {
- return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=session");
- } catch (\Exception_ServiceUnavailable $e) {
- return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=maintenance");
- } catch (\Exception_Session_BadSalinity $e) {
- $date = new \DateTime('5 minutes');
- $usr_id = \User_Adapter::get_usr_id_from_login($request->get('login'));
- $url = \random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $date);
-
- $url = '/account/forgot-password/?token=' . $url . '&salt=1';
-
- return $app->redirect($url);
- } catch (\Exception $e) {
- return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=" . _('An error occured'));
- }
-
- if ($app['browser']->isMobile()) {
- return $app->redirect("/lightbox/");
- } elseif ($request->get('redirect')) {
- return $app->redirect($request->get('redirect'));
- } elseif (true !== $app['browser']->isNewGeneration()) {
- return $app->redirect('/client/');
- } else {
- return $app->redirect('/prod/');
- }
- } else {
- return $app->redirect("/login/");
- }
- }
-}
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php
index 87b641db7e..dc280a89b1 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Account.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php
@@ -13,7 +13,9 @@ namespace Alchemy\Phrasea\Controller\Root;
use Silex\Application;
use Silex\ControllerProviderInterface;
+use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
/**
@@ -45,7 +47,8 @@ class Account implements ControllerProviderInterface
*
* return : HTML Response
*/
- $controllers->get('/', $this->call('displayAccount'))->bind('account');
+ $controllers->get('/', $this->call('displayAccount'))
+ ->bind('account');
/**
* Update account route
@@ -152,7 +155,8 @@ class Account implements ControllerProviderInterface
*
* return : HTML Response
*/
- $controllers->get('/access/', $this->call('accountAccess'))->bind('account_access');
+ $controllers->get('/access/', $this->call('accountAccess'))
+ ->bind('account_access');
/**
* Give authorized applications that can access user informations
@@ -167,7 +171,8 @@ class Account implements ControllerProviderInterface
*
* return : HTML Response
*/
- $controllers->post('/reset-email/', $this->call('resetEmail'))->bind('reset_email');
+ $controllers->post('/reset-email/', $this->call('resetEmail'))
+ ->bind('reset_email');
/**
* Grant access to an authorized app
@@ -182,7 +187,8 @@ class Account implements ControllerProviderInterface
*
* return : HTML Response
*/
- $controllers->get('/reset-password/', $this->call('resetPassword'))->bind('reset_password');
+ $controllers->get('/reset-password/', $this->call('resetPassword'))
+ ->bind('reset_password');
/**
* Give account open sessions
@@ -239,9 +245,9 @@ class Account implements ControllerProviderInterface
/**
* Reset Password
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\Response
+ * @param Application $app
+ * @param Request $request
+ * @return Response
*/
public function resetPassword(Application $app, Request $request)
{
@@ -267,9 +273,9 @@ class Account implements ControllerProviderInterface
/**
* Reset Email
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\JsonResponse
+ * @param Application $app
+ * @param Request $request
+ * @return RedirectResponse
*/
public function resetEmail(Application $app, Request $request)
{
@@ -326,9 +332,9 @@ class Account implements ControllerProviderInterface
/**
* Display reset email form
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\JsonResponse
+ * @param Application $app
+ * @param Request $request
+ * @return Response
*/
public function displayResetEmailForm(Application $app, Request $request)
{
@@ -372,9 +378,9 @@ class Account implements ControllerProviderInterface
/**
* Submit the new password
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return RedirectResponse
*/
public function renewPassword(Application $app, Request $request)
{
@@ -410,10 +416,9 @@ class Account implements ControllerProviderInterface
/**
* Display authorized applications that can access user informations
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return JsonResponse
*/
public function grantAccess(Application $app, Request $request, $application_id)
{
@@ -442,10 +447,9 @@ class Account implements ControllerProviderInterface
/**
* Display account base access
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function accountAccess(Application $app, Request $request)
{
@@ -459,10 +463,9 @@ class Account implements ControllerProviderInterface
/**
* Display authorized applications that can access user informations
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function accountAuthorizedApps(Application $app, Request $request)
{
@@ -474,10 +477,9 @@ class Account implements ControllerProviderInterface
/**
* Display account session accesss
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function accountSessionsAccess(Application $app, Request $request)
{
@@ -487,10 +489,9 @@ class Account implements ControllerProviderInterface
/**
* Display account form
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function displayAccount(Application $app, Request $request)
{
@@ -530,7 +531,6 @@ class Account implements ControllerProviderInterface
*
* @param Application $app A Silex application where the controller is mounted on
* @param Request $request The current request
- *
* @return Response
*/
public function updateAccount(Application $app, Request $request)
@@ -550,7 +550,7 @@ class Account implements ControllerProviderInterface
$register->add_request($user, \collection::get_from_base_id($baseId));
$notice = 'demand-ok';
} catch (\Exception $e) {
- exit($e->getMessage());
+
}
}
}
@@ -630,7 +630,7 @@ class Account implements ControllerProviderInterface
$notifId = $notification['id'];
$notifName = sprintf('notification_%d', $notifId);
- if (in_array($notifId, $requestedNotifications)) {
+ if (isset($requestedNotifications[$notifId])) {
$user->setPrefs($notifName, '1');
} else {
$user->setPrefs($notifName, '0');
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Developers.php b/lib/Alchemy/Phrasea/Controller/Root/Developers.php
index 573d6ac6d4..f401005cee 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Developers.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Developers.php
@@ -13,7 +13,9 @@ namespace Alchemy\Phrasea\Controller\Root;
use Silex\Application;
use Silex\ControllerProviderInterface;
+use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
/**
@@ -175,11 +177,10 @@ class Developers implements ControllerProviderInterface
/**
* Delete application
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- * @param integer $id The application id
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @param integer $id The application id
+ * @return JsonResponse
*/
public function deleteApp(Application $app, Request $request, $id)
{
@@ -202,11 +203,10 @@ class Developers implements ControllerProviderInterface
/**
* Change application callback
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- * @param integer $id The application id
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @param integer $id The application id
+ * @return JsonResponse
*/
public function renewAppCallback(Application $app, Request $request, $id)
{
@@ -234,11 +234,10 @@ class Developers implements ControllerProviderInterface
/**
* Authorize application to use a grant password type
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- * @param integer $id The application id
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @param integer $id The application id
+ * @return JsonResponse
*/
public function renewAccessToken(Application $app, Request $request, $id)
{
@@ -273,11 +272,10 @@ class Developers implements ControllerProviderInterface
/**
* Authorize application to use a grant password type
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- * @param integer $id The application id
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @param integer $id The application id
+ * @return JsonResponse
*/
public function authorizeGrantpassword(Application $app, Request $request, $id)
{
@@ -300,14 +298,13 @@ class Developers implements ControllerProviderInterface
/**
* Create a new developer applications
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function newApp(Application $app, Request $request)
{
- if ($request->get('type') == "desktop") {
+ if ($request->get('type') === \API_OAuth2_Application::DESKTOP_TYPE) {
$form = new \API_OAuth2_Form_DevAppDesktop($app['request']);
} else {
$form = new \API_OAuth2_Form_DevAppInternet($app['request']);
@@ -337,10 +334,9 @@ class Developers implements ControllerProviderInterface
/**
* List of apps created by the user
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function listApps(Application $app, Request $request)
{
@@ -353,10 +349,9 @@ class Developers implements ControllerProviderInterface
/**
* Display form application
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function displayFormApp(Application $app, Request $request)
{
@@ -370,11 +365,10 @@ class Developers implements ControllerProviderInterface
/**
* Get application information
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- * @param integer $id The application id
- *
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @param integer $id The application id
+ * @return Response
*/
public function getApp(Application $app, Request $request, $id)
{
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php
index 0311494f2e..b0624e5b5e 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Login.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php
@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Core;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
/**
@@ -44,18 +45,47 @@ class Login implements ControllerProviderInterface
*/
$controllers->get('/', $this->call('login'))
->before(function() use ($app) {
-//
-// if ( ! $app['phraseanet.appbox']->get_session()->isset_postlog()
-// && $app['phraseanet.core']->isAuthenticated()
-// && $app['request']->get('error') != 'no-connection') {
-//
-// return $app->redirect($app['request']->get('redirect', '/prod/'));
-// }
- return $app['phraseanet.core']['Firewall']->requireNotAuthenticated($app);
+ if (null !== $app['request']->get('postlog')) {
+
+ // if isset postlog parameter, set cookie and log out current user
+ // then post login operation like getting baskets from an invit session
+ // could be done by Session_handler authentication process
+
+ $app['phraseanet.appbox']->get_session()->set_postlog();
+
+ return $app->redirect("/login/logout/?redirect=" . $app['request']->get('redirect', 'prod'));
+ }
+
+
+ if ($app['phraseanet.core']->isAuthenticated()) {
+
+ return $app->redirect('/' . $app['request']->get('redirect', 'prod') . '/');
+ }
})
->bind('homepage');
+ /**
+ * Authenticate
+ *
+ * name : login_authenticate
+ *
+ * description : authenticate to phraseanet
+ *
+ * method : POST
+ *
+ * parameters : none
+ *
+ * return : HTML Response
+ */
+ $controllers->post('/authenticate/', $this->call('authenticate'))
+ ->before(function() use ($app) {
+ if ($app['phraseanet.core']->isAuthenticated()) {
+ return $app->redirect('/prod/');
+ }
+ })
+ ->bind('login_authenticate');
+
/**
* Logout
*
@@ -174,9 +204,9 @@ class Login implements ControllerProviderInterface
/**
* Send a confirmation mail after register
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return RedirectResponse
*/
public function sendConfirmMail(Application $app, Request $request)
{
@@ -201,9 +231,9 @@ class Login implements ControllerProviderInterface
/**
* Validation of email adress
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return RedirectResponse
*/
public function registerConfirm(Application $app, Request $request)
{
@@ -262,9 +292,9 @@ class Login implements ControllerProviderInterface
/**
* Submit the new password
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return RedirectResponse
*/
public function renewPassword(Application $app, Request $request)
{
@@ -327,9 +357,9 @@ class Login implements ControllerProviderInterface
/**
* Get the fogot password form
*
- * @param Application $app A Silex application where the controller is mounted on
- * @param Request $request The current request
- * @return Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function displayForgotPasswordForm(Application $app, Request $request)
{
@@ -398,9 +428,9 @@ class Login implements ControllerProviderInterface
/**
* Get the register form
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function displayRegisterForm(Application $app, Request $request)
{
@@ -458,9 +488,9 @@ class Login implements ControllerProviderInterface
/**
* Get the register form
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return RedirectResponse
*/
public function register(Application $app, Request $request)
{
@@ -617,9 +647,9 @@ class Login implements ControllerProviderInterface
/**
* Logout from Phraseanet
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return RedirectResponse
*/
public function logout(Application $app, Request $request)
{
@@ -640,27 +670,20 @@ class Login implements ControllerProviderInterface
/**
* Login into Phraseanet
*
- * @param \Silex\Application $app
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @return \Symfony\Component\HttpFoundation\Response
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return Response
*/
public function login(Application $app, Request $request)
{
$appbox = $app['phraseanet.appbox'];
- $session = $appbox->get_session();
- $registry = $appbox->get_registry();
+ $registry = $app['phraseanet.core']['Registry'];
require_once($registry->get('GV_RootPath') . 'lib/classes/deprecated/inscript.api.php');
if ($registry->get('GV_captchas') && trim($registry->get('GV_captcha_private_key')) !== '' && trim($registry->get('GV_captcha_public_key')) !== '') {
include($registry->get('GV_RootPath') . 'lib/vendor/recaptcha/recaptchalib.php');
}
- if ($request->get('postlog')) {
- $session->set_postlog(true);
-
- return $app->redirect("/login/?redirect=" . $request->get('redirect'));
- }
-
$warning = $request->get('error', '');
try {
@@ -758,6 +781,97 @@ class Login implements ControllerProviderInterface
));
}
+ /**
+ * Authenticate to phraseanet
+ *
+ * @param Application $app A Silex application where the controller is mounted on
+ * @param Request $request The current request
+ * @return RedirectResponse
+ */
+ public function authenticate(Application $app, Request $request)
+ {
+ $appbox = $app['phraseanet.appbox'];
+ $session = $appbox->get_session();
+ $registry = $app['phraseanet.core']['Registry'];
+
+ $is_guest = false;
+
+ if (null !== $request->get('nolog') && \phrasea::guest_allowed()) {
+ $is_guest = true;
+ }
+
+ if (((null !== $login = $request->get('login')) && (null !== $pwd = $request->get('pwd'))) || $is_guest) {
+
+ /**
+ * @todo dispatch an event that can be used to tweak the authentication
+ * (LDAP....)
+ */
+ // $app['dispatcher']->dispatch();
+
+ try {
+ if ($is_guest) {
+ $auth = new \Session_Authentication_Guest($appbox);
+ } else {
+ $captcha = false;
+
+ if ($registry->get('GV_captchas')
+ && '' !== $privateKey = trim($registry->get('GV_captcha_private_key'))
+ && trim($registry->get('GV_captcha_public_key')) !== ''
+ && null !== $challenge = $request->get("recaptcha_challenge_field")
+ && null !== $captachResponse = $request->get("recaptcha_response_field")) {
+
+ include($registry->get('GV_RootPath') . 'lib/vendor/recaptcha/recaptchalib.php');
+
+ $checkCaptcha = recaptcha_check_answer($privateKey, $_SERVER["REMOTE_ADDR"], $challenge, $captachResponse);
+
+ if ($checkCaptcha->is_valid) {
+ $captcha = true;
+ }
+ }
+
+ $auth = new \Session_Authentication_Native($appbox, $login, $pwd);
+ $auth->set_captcha_challenge($captcha);
+ }
+
+ $session->authenticate($auth);
+ } catch (\Exception_Session_StorageClosed $e) {
+ return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=session");
+ } catch (\Exception_Session_RequireCaptcha $e) {
+ return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=captcha");
+ } catch (\Exception_Unauthorized $e) {
+ return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=auth");
+ } catch (\Exception_Session_MailLocked $e) {
+ return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=mail-not-confirmed&usr=" . $e->get_usr_id());
+ } catch (\Exception_Session_WrongToken $e) {
+ return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=token");
+ } catch (\Exception_InternalServerError $e) {
+ return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=session");
+ } catch (\Exception_ServiceUnavailable $e) {
+ return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=maintenance");
+ } catch (\Exception_Session_BadSalinity $e) {
+ $date = new \DateTime('5 minutes');
+ $usr_id = \User_Adapter::get_usr_id_from_login($request->get('login'));
+ $url = '/account/forgot-password/?token=' . \random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $date) . '&salt=1';
+
+ return $app->redirect($url);
+ } catch (\Exception $e) {
+ return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=" . _('An error occured'));
+ }
+
+ if ($app['browser']->isMobile()) {
+ return $app->redirect("/lightbox/");
+ } elseif ($request->get('redirect')) {
+ return $app->redirect($request->get('redirect'));
+ } elseif (true !== $app['browser']->isNewGeneration()) {
+ return $app->redirect('/client/');
+ } else {
+ return $app->redirect('/prod/');
+ }
+ } else {
+ return $app->redirect("/login/");
+ }
+ }
+
/**
* Prefix the method to call with the controller class name
*
@@ -772,7 +886,7 @@ class Login implements ControllerProviderInterface
/**
* Get required fields configuration
*
- * @param \Alchemy\Phrasea\Core $core
+ * @param Core $core
* @return boolean
*/
private function getRegisterFieldConfiguration(Core $core)
@@ -799,14 +913,13 @@ class Login implements ControllerProviderInterface
"demand" => true
);
- //on va chercher le fichier de configuration
$registerFieldConfigurationFile = $core['Registry']->get('GV_RootPath') . 'config/register-fields.php';
if (is_file($registerFieldConfigurationFile)) {
include $registerFieldConfigurationFile;
}
- //on force les champs vraiment obligatoires si le mec a fumé en faisant sa conf
+ //Override mandatory fields
$arrayVerif['form_login'] = true;
$arrayVerif['form_password'] = true;
$arrayVerif['form_password_confirm'] = true;
diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php
index 7d0d6f2a4c..2c2c4eac78 100644
--- a/lib/Alchemy/Phrasea/Helper/User/Manage.php
+++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php
@@ -180,7 +180,7 @@ class Manage extends Helper
$registry = \bootstrap::getCore()->getRegistry();
if (false !== $urlToken) {
- $url = sprintf('%slogin/forgotpwd.php?token=%s', $registry->get('GV_ServerName'), $urlToken);
+ $url = sprintf('%slogin/forgot-password/?token=%s', $registry->get('GV_ServerName'), $urlToken);
\mail::send_credentials($url, $createdUser->get_login(), $createdUser->get_email());
}
}
diff --git a/lib/Alchemy/Phrasea/Security/Firewall.php b/lib/Alchemy/Phrasea/Security/Firewall.php
index e8d50592ce..f73c23641a 100644
--- a/lib/Alchemy/Phrasea/Security/Firewall.php
+++ b/lib/Alchemy/Phrasea/Security/Firewall.php
@@ -34,11 +34,4 @@ class Firewall
return $app->redirect('/login/logout/');
}
}
-
- public function requireNotAuthenticated(Application $app)
- {
- if ($app['phraseanet.core']->isAuthenticated()) {
- return $app->redirect('/prod/');
- }
- }
}
diff --git a/lib/classes/Exception/ServiceUnavalaible.class.php b/lib/classes/Exception/ServiceUnavailable.class.php
similarity index 100%
rename from lib/classes/Exception/ServiceUnavalaible.class.php
rename to lib/classes/Exception/ServiceUnavailable.class.php
diff --git a/lib/classes/eventsmanager/notify/autoregister.class.php b/lib/classes/eventsmanager/notify/autoregister.class.php
index 3d21253308..fce6569b85 100644
--- a/lib/classes/eventsmanager/notify/autoregister.class.php
+++ b/lib/classes/eventsmanager/notify/autoregister.class.php
@@ -246,7 +246,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$body .= "\n";
- $body .= "
\n