mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
Address PR comments
This commit is contained in:
@@ -574,11 +574,21 @@ class Application extends SilexApplication
|
||||
return $this['session']->getFlashBag()->get($type, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a temporary unlock data for a account-locked user
|
||||
*
|
||||
* @param integer $usr_id
|
||||
*/
|
||||
public function addUnlockLink($usr_id)
|
||||
{
|
||||
$this['session']->set('unlock_user_id', $usr_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the temporary unlock data
|
||||
*
|
||||
* @return null|integer
|
||||
*/
|
||||
public function getUnlockLink()
|
||||
{
|
||||
if ($this['session']->has('unlock_user_id')) {
|
||||
|
@@ -34,7 +34,9 @@ class Lightbox implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
if (false === $usr_id = $app['authentication.token-validator']->isValid($request->query->get('LOG'))) {
|
||||
return $app->redirect("/login/?error=" . urlencode($e->getMessage()));
|
||||
$app->addFlash('error', _('The URL you used is out of date, please login'));
|
||||
|
||||
return $app->redirect($app->path('homepage'));
|
||||
}
|
||||
|
||||
$app['authentication']->openAccount(\User_Adapter::getInstance($usr_id, $app));
|
||||
|
@@ -46,7 +46,6 @@ interface ProviderInterface
|
||||
*/
|
||||
public function authenticate();
|
||||
|
||||
|
||||
/**
|
||||
* This method is called on provider callback, whenever the auth was
|
||||
* successful or failure.
|
||||
|
@@ -22,6 +22,12 @@ class TokenValidator
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the token is valid
|
||||
*
|
||||
* @param type $token
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValid($token)
|
||||
{
|
||||
try {
|
||||
|
@@ -27,7 +27,6 @@ class Root implements ControllerProviderInterface
|
||||
->get('/language/{locale}/', $this->call('setLocale'))
|
||||
->bind('set_locale');
|
||||
|
||||
|
||||
$controllers
|
||||
->get('/', $this->call('getRoot'))
|
||||
->bind('root');
|
||||
|
@@ -41,7 +41,6 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
|
||||
return new CookieManager($app['auth.password-encoder'], $app['EM'], $app['browser']);
|
||||
});
|
||||
|
||||
|
||||
$app['authentication.suggestion-finder'] = $app->share(function (Application $app) {
|
||||
return new SuggestionFinder($app);
|
||||
});
|
||||
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Core\Provider;
|
||||
|
||||
use Alchemy\Phrasea\Core\Provider\RegistrationServiceProvider;
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Core\Provider\RegistrationServiceProvider
|
||||
*/
|
||||
class RegistrationServiceProvidertest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
public function testSameInstanceShouldBereturnedEveryTime()
|
||||
{
|
||||
self::$DI['app']->register(new RegistrationServiceProvider());
|
||||
|
||||
self::$DI['app']['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['phraseanet.configuration']->expects($this->once())
|
||||
->method('has')
|
||||
->with('registration-fields')
|
||||
->will($this->returnValue(true));
|
||||
self::$DI['app']['phraseanet.configuration']->expects($this->once())
|
||||
->method('get')
|
||||
->with('registration-fields')
|
||||
->will($this->returnValue(array('plop')));
|
||||
|
||||
$this->assertEquals(array('plop'), self::$DI['app']['registration.fields']);
|
||||
$this->assertEquals(array('plop'), self::$DI['app']['registration.fields']);
|
||||
|
||||
$this->assertInternalType('array', self::$DI['app']['registration.optional-fields']);
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ namespace Alchemy\Tests\Phrasea\Form\Login;
|
||||
|
||||
use Alchemy\Phrasea\Form\Login\PhraseaRegisterForm;;
|
||||
use Alchemy\Tests\Phrasea\Form\FormTestCase;
|
||||
use Alchemy\Phrasea\Utilities\String\Camelizer;
|
||||
|
||||
class PhraseaRegisterFormTest extends FormTestCase
|
||||
{
|
||||
@@ -22,6 +23,58 @@ class PhraseaRegisterFormTest extends FormTestCase
|
||||
)
|
||||
);
|
||||
|
||||
return new PhraseaRegisterForm(self::$DI['app'], $available, $params, new \Alchemy\Phrasea\Utilities\String\Camelizer());
|
||||
return new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer());
|
||||
}
|
||||
|
||||
public function testFormDoesRegisterValidFields()
|
||||
{
|
||||
$available = array(
|
||||
'parameter' => array(
|
||||
'type' => 'text',
|
||||
'label' => 'Yollah !',
|
||||
),
|
||||
'parameter2' => array(
|
||||
'type' => 'text',
|
||||
'label' => 'Yollah !',
|
||||
)
|
||||
);
|
||||
$params = array(
|
||||
array(
|
||||
'name' => 'parameter',
|
||||
'required' => true
|
||||
),
|
||||
array(
|
||||
'name' => 'parameter2',
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
|
||||
$form = new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer());
|
||||
|
||||
$this->assertCount(8, self::$DI['app']->form($form)->createView()->vars['form']->children);
|
||||
}
|
||||
|
||||
public function testFormDoesNotRegisterNonValidFields()
|
||||
{
|
||||
$available = array(
|
||||
'parameter' => array(
|
||||
'type' => 'text',
|
||||
'label' => 'Yollah !',
|
||||
)
|
||||
);
|
||||
$params = array(
|
||||
array(
|
||||
'name' => 'parameter',
|
||||
'required' => true
|
||||
),
|
||||
array(
|
||||
'name' => 'parameter2',
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
|
||||
$form = new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer());
|
||||
|
||||
$this->assertCount(7, self::$DI['app']->form($form)->createView()->vars['form']->children);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user