mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 14:33:14 +00:00
Fix #1570 Remove accept tou link if there are no TOU
This commit is contained in:
@@ -58,14 +58,16 @@ class PhraseaRegisterForm extends AbstractType
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$builder->add('accept-tou', 'checkbox', array(
|
if ($this->app->hasTermsOfUse()) {
|
||||||
'label' => _('Terms of Use'),
|
$builder->add('accept-tou', 'checkbox', array(
|
||||||
'mapped' => false,
|
'label' => _('Terms of Use'),
|
||||||
"constraints" => array(
|
'mapped' => false,
|
||||||
new Assert\True(array(
|
"constraints" => array(
|
||||||
"message" => _("Please accept the Terms and conditions in order to register.")
|
new Assert\True(array(
|
||||||
))),
|
"message" => _("Please accept the Terms and conditions in order to register.")
|
||||||
));
|
))),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
$builder->add('provider-id', 'hidden');
|
$builder->add('provider-id', 'hidden');
|
||||||
|
|
||||||
|
@@ -59,17 +59,19 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<div class="row-fluid">
|
{% if has_terms_of_use %}
|
||||||
<div class="span12">
|
<div class="row-fluid">
|
||||||
{% set label %}
|
<div class="span12">
|
||||||
<a target="_blank" href="{{ path("login_cgus") }}">
|
{% set label %}
|
||||||
{% trans "I have read the terms of use" %}
|
<a target="_blank" href="{{ path("login_cgus") }}">
|
||||||
</a>
|
{% trans "I have read the terms of use" %}
|
||||||
{% endset %}
|
</a>
|
||||||
|
{% endset %}
|
||||||
|
|
||||||
{{ auth_macro.checkboxInput(form['accept-tou'], label) }}
|
{{ auth_macro.checkboxInput(form['accept-tou'], label) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
|
|
||||||
{# form.collections is not defined if current instance is configured with auto collection selection #}
|
{# form.collections is not defined if current instance is configured with auto collection selection #}
|
||||||
{% if form.collections is defined %}
|
{% if form.collections is defined %}
|
||||||
|
@@ -60,17 +60,19 @@
|
|||||||
* {% trans "Mandatory fields" %}
|
* {% trans "Mandatory fields" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row-fluid">
|
{% if has_terms_of_use %}
|
||||||
<div class="span12">
|
<div class="row-fluid">
|
||||||
{% set label %}
|
<div class="span12">
|
||||||
<a href="{{ path("login_cgus") }}">
|
{% set label %}
|
||||||
{% trans "I have read the terms of use" %}
|
<a href="{{ path("login_cgus") }}">
|
||||||
</a>
|
{% trans "I have read the terms of use" %}
|
||||||
{% endset %}
|
</a>
|
||||||
|
{% endset %}
|
||||||
|
|
||||||
{{ auth_macro.checkboxInput(form['remember-me']) }}
|
{{ auth_macro.checkboxInput(form['remember-me']) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
|
|
||||||
{{ form_rest(form) }}
|
{{ form_rest(form) }}
|
||||||
|
|
||||||
|
@@ -20,6 +20,8 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
public static $login;
|
public static $login;
|
||||||
public static $email;
|
public static $email;
|
||||||
|
|
||||||
|
private static $termsOfUse;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -45,6 +47,50 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
$this->resetTOU();
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRegisterWithNoTou()
|
||||||
|
{
|
||||||
|
$this->logout(self::$DI['app']);
|
||||||
|
$this->disableTOU();
|
||||||
|
self::$DI['client']->followRedirects();
|
||||||
|
$crawler = self::$DI['client']->request('GET', '/login/register-classic');
|
||||||
|
$this->assertEquals(0, $crawler->filter('a[href="'.self::$DI['app']->path('login_cgus').'"]')->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRegisterWithTou()
|
||||||
|
{
|
||||||
|
$this->logout(self::$DI['app']);
|
||||||
|
$this->enableTOU();
|
||||||
|
self::$DI['client']->followRedirects();
|
||||||
|
$crawler = self::$DI['client']->request('GET', '/login/register-classic');
|
||||||
|
$this->assertEquals(2, $crawler->filter('a[href="'.self::$DI['app']->path('login_cgus').'"]')->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRegisterWithAutoSelect()
|
||||||
|
{
|
||||||
|
$this->logout(self::$DI['app']);
|
||||||
|
$gvAutoSelectDb = !! self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB');
|
||||||
|
self::$DI['app']['phraseanet.registry']->set('GV_autoselectDB', false, \registry::TYPE_BOOLEAN);
|
||||||
|
$crawler = self::$DI['client']->request('GET', '/login/register-classic/');
|
||||||
|
$this->assertEquals(1, $crawler->filter('select[name="collections[]"]')->count());
|
||||||
|
self::$DI['app']['phraseanet.registry']->set('GV_autoselectDB', $gvAutoSelectDb, \registry::TYPE_BOOLEAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRegisterWithNoAutoSelect()
|
||||||
|
{
|
||||||
|
$this->logout(self::$DI['app']);
|
||||||
|
$gvAutoSelectDb = !! self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB');
|
||||||
|
self::$DI['app']['phraseanet.registry']->set('GV_autoselectDB', true, \registry::TYPE_BOOLEAN);
|
||||||
|
$crawler = self::$DI['client']->request('GET', '/login/register-classic/');
|
||||||
|
$this->assertEquals(0, $crawler->filter('select[name="collections[]"]')->count());
|
||||||
|
self::$DI['app']['phraseanet.registry']->set('GV_autoselectDB', $gvAutoSelectDb, \registry::TYPE_BOOLEAN);
|
||||||
|
}
|
||||||
|
|
||||||
public function testLoginAlreadyAthenticated()
|
public function testLoginAlreadyAthenticated()
|
||||||
{
|
{
|
||||||
self::$DI['client']->request('GET', '/login/');
|
self::$DI['client']->request('GET', '/login/');
|
||||||
@@ -70,9 +116,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
{
|
{
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
self::$DI['app']->addFlash($type, $message);
|
self::$DI['app']->addFlash($type, $message);
|
||||||
|
|
||||||
$crawler = self::$DI['client']->request('GET', '/login/');
|
$crawler = self::$DI['client']->request('GET', '/login/');
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
$response = self::$DI['client']->getResponse();
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$this->assertFlashMessage($crawler, $type, 1, $message);
|
$this->assertFlashMessage($crawler, $type, 1, $message);
|
||||||
@@ -86,7 +130,6 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
self::$DI['client']->request('GET', '/login/register-confirm/');
|
self::$DI['client']->request('GET', '/login/register-confirm/');
|
||||||
$response = self::$DI['client']->getResponse();
|
$response = self::$DI['client']->getResponse();
|
||||||
|
|
||||||
$this->assertTrue($response->isRedirect());
|
$this->assertTrue($response->isRedirect());
|
||||||
$this->assertFlashMessagePopulated(self::$DI['app'], 'error', 1);
|
$this->assertFlashMessagePopulated(self::$DI['app'], 'error', 1);
|
||||||
$this->assertEquals('/login/', $response->headers->get('location'));
|
$this->assertEquals('/login/', $response->headers->get('location'));
|
||||||
@@ -496,8 +539,9 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
/**
|
/**
|
||||||
* @dataProvider provideInvalidRegistrationData
|
* @dataProvider provideInvalidRegistrationData
|
||||||
*/
|
*/
|
||||||
public function testPostRegisterbadArguments($parameters, $extraParameters, $errors)
|
public function testPostRegisterBadArguments($parameters, $extraParameters, $errors)
|
||||||
{
|
{
|
||||||
|
$this->enableTOU();
|
||||||
self::$DI['app']['registration.enabled'] = true;
|
self::$DI['app']['registration.enabled'] = true;
|
||||||
self::$DI['app']['registration.fields'] = $extraParameters;
|
self::$DI['app']['registration.fields'] = $extraParameters;
|
||||||
|
|
||||||
@@ -521,13 +565,13 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$crawler = self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
|
$crawler = self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
|
||||||
|
|
||||||
$this->assertFalse(self::$DI['client']->getResponse()->isRedirect());
|
$this->assertFalse(self::$DI['client']->getResponse()->isRedirect());
|
||||||
$this->assertFormOrFlashError($crawler, $errors);
|
$this->assertFormOrFlashError($crawler, $errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPostRegisterWithoutParams()
|
public function testPostRegisterWithoutParams()
|
||||||
{
|
{
|
||||||
|
$this->enableTOU();
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
$crawler = self::$DI['client']->request('POST', '/login/register-classic/');
|
$crawler = self::$DI['client']->request('POST', '/login/register-classic/');
|
||||||
|
|
||||||
@@ -781,6 +825,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testPostRegisterWithProviderIdAndAlreadyBoundProvider()
|
public function testPostRegisterWithProviderIdAndAlreadyBoundProvider()
|
||||||
{
|
{
|
||||||
|
$this->enableTOU();
|
||||||
self::$DI['app']['registration.fields'] = array();
|
self::$DI['app']['registration.fields'] = array();
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
|
|
||||||
@@ -831,6 +876,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testPostRegisterWithUnknownProvider()
|
public function testPostRegisterWithUnknownProvider()
|
||||||
{
|
{
|
||||||
|
$this->enableTOU();
|
||||||
self::$DI['app']['registration.fields'] = array();
|
self::$DI['app']['registration.fields'] = array();
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
|
|
||||||
@@ -866,6 +912,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testPostRegisterWithProviderNotAuthenticated()
|
public function testPostRegisterWithProviderNotAuthenticated()
|
||||||
{
|
{
|
||||||
|
$this->enableTOU();
|
||||||
self::$DI['app']['registration.fields'] = array();
|
self::$DI['app']['registration.fields'] = array();
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
|
|
||||||
@@ -908,6 +955,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testPostRegisterWithProviderId()
|
public function testPostRegisterWithProviderId()
|
||||||
{
|
{
|
||||||
|
$this->enableTOU();
|
||||||
self::$DI['app']['registration.fields'] = array();
|
self::$DI['app']['registration.fields'] = array();
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
|
|
||||||
@@ -981,6 +1029,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
*/
|
*/
|
||||||
public function testPostRegister($parameters, $extraParameters)
|
public function testPostRegister($parameters, $extraParameters)
|
||||||
{
|
{
|
||||||
|
$this->enableTOU();
|
||||||
self::$DI['app']['registration.fields'] = $extraParameters;
|
self::$DI['app']['registration.fields'] = $extraParameters;
|
||||||
|
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
@@ -1006,7 +1055,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB')) {
|
if (self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB')) {
|
||||||
unset($parameters['collections']);
|
unset($parameters['collections']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1753,4 +1802,50 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
{
|
{
|
||||||
return \random::generatePassword() . '_email@email.com';
|
return \random::generatePassword() . '_email@email.com';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function disableTOU()
|
||||||
|
{
|
||||||
|
if (null === self::$termsOfUse) {
|
||||||
|
self::$termsOfUse = array();
|
||||||
|
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||||
|
self::$termsOfUse[$databox->get_sbas_id()] = $databox->get_cgus();
|
||||||
|
|
||||||
|
foreach( self::$termsOfUse[$databox->get_sbas_id()]as $lng => $tou) {
|
||||||
|
$databox->update_cgus($lng, '', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function enableTOU()
|
||||||
|
{
|
||||||
|
if (null === self::$termsOfUse) {
|
||||||
|
self::$termsOfUse = array();
|
||||||
|
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||||
|
self::$termsOfUse[$databox->get_sbas_id()] = $databox->get_cgus();
|
||||||
|
|
||||||
|
foreach( self::$termsOfUse[$databox->get_sbas_id()]as $lng => $tou) {
|
||||||
|
$databox->update_cgus($lng, 'something', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resetTOU()
|
||||||
|
{
|
||||||
|
if (null === self::$termsOfUse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||||
|
if (!isset(self::$termsOfUse[$databox->get_sbas_id()])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tous = self::$termsOfUse[$databox->get_sbas_id()];
|
||||||
|
foreach ($tous as $lng => $tou) {
|
||||||
|
$databox->update_cgus($lng, $tou['value'], false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$termsOfUse = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,8 @@ require([
|
|||||||
}, function () {
|
}, function () {
|
||||||
Common.initialize();
|
Common.initialize();
|
||||||
|
|
||||||
var rules = [
|
var rules = [];
|
||||||
|
var defaultRules = [
|
||||||
{
|
{
|
||||||
name: "email",
|
name: "email",
|
||||||
rules: "required",
|
rules: "required",
|
||||||
@@ -85,7 +86,13 @@ require([
|
|||||||
"message": i18n.t("validation_blank")
|
"message": i18n.t("validation_blank")
|
||||||
};
|
};
|
||||||
|
|
||||||
rules.push(rule);
|
defaultRules.push(rule);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_.each(defaultRules, function (rule) {
|
||||||
|
// add rule if element exists
|
||||||
|
if ($("[name='" + rule.name + "']").length >= 1) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -30,7 +30,8 @@ require([
|
|||||||
resGetPath: Common.languagePath,
|
resGetPath: Common.languagePath,
|
||||||
useLocalStorage: true
|
useLocalStorage: true
|
||||||
}, function () {
|
}, function () {
|
||||||
var rules = [
|
var rules = [];
|
||||||
|
var defaultRules = [
|
||||||
{
|
{
|
||||||
name: "email",
|
name: "email",
|
||||||
rules: "required",
|
rules: "required",
|
||||||
@@ -84,6 +85,13 @@ require([
|
|||||||
"message": i18n.t("validation_blank")
|
"message": i18n.t("validation_blank")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaultRules.push(rule);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_.each(defaultRules, function (rule) {
|
||||||
|
// add rule if element exists
|
||||||
|
if ($("[name='" + rule.name + "']").length >= 1) {
|
||||||
rules.push(rule);
|
rules.push(rule);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user