summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-01-18 01:00:17 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-01-18 01:00:17 +0100
commit41033768c3eacbd564c3ec15455587e4f725a055 (patch)
tree461e38fa717d4ceec58e9caeab98e6f5ab5198ee
parentfb908d45577cd0f156104eb23b4b9859d40b6da2 (diff)
Mode anonyme pour connexion avec formulaire
Contribue à https://github.com/marienfressinaud/FreshRSS/issues/361
-rw-r--r--app/Controllers/usersController.php2
-rw-r--r--app/views/configure/users.phtml18
-rw-r--r--lib/Minz/Configuration.php9
3 files changed, 10 insertions, 19 deletions
diff --git a/app/Controllers/usersController.php b/app/Controllers/usersController.php
index 7e44b3d35..a044cd25b 100644
--- a/app/Controllers/usersController.php
+++ b/app/Controllers/usersController.php
@@ -57,8 +57,8 @@ class FreshRSS_users_Controller extends Minz_ActionController {
$auth_type = Minz_Request::param('auth_type', 'none');
if ($anon != Minz_Configuration::allowAnonymous() ||
$auth_type != Minz_Configuration::authType()) {
- Minz_Configuration::_allowAnonymous($anon);
Minz_Configuration::_authType($auth_type);
+ Minz_Configuration::_allowAnonymous($anon);
$ok &= Minz_Configuration::writeFile();
}
}
diff --git a/app/views/configure/users.phtml b/app/views/configure/users.phtml
index 602dfaf62..3f352f9bf 100644
--- a/app/views/configure/users.phtml
+++ b/app/views/configure/users.phtml
@@ -58,20 +58,11 @@
</div>
</div>
- <div class="form-group form-actions">
- <div class="group-controls">
- <button type="submit" class="btn btn-important"><?php echo Minz_Translate::t('save'); ?></button>
- <button type="reset" class="btn"><?php echo Minz_Translate::t('cancel'); ?></button>
- </div>
- </div>
-
- <?php if (Minz_Configuration::authType() === 'persona') { ?>
-
- <legend>Mozilla Persona</legend>
<div class="form-group">
<div class="group-controls">
<label class="checkbox" for="anon_access">
- <input type="checkbox" name="anon_access" id="anon_access" value="1"<?php echo Minz_Configuration::allowAnonymous() ? ' checked="checked"' : ''; ?> />
+ <input type="checkbox" name="anon_access" id="anon_access" value="1"<?php echo Minz_Configuration::allowAnonymous() ? ' checked="checked"' : '',
+ Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> />
<?php echo Minz_Translate::t('allow_anonymous', Minz_Configuration::defaultUser()); ?>
</label>
</div>
@@ -81,7 +72,8 @@
<label class="group-name" for="token"><?php echo Minz_Translate::t('auth_token'); ?></label>
<?php $token = $this->conf->token; ?>
<div class="group-controls">
- <input type="text" id="token" name="token" value="<?php echo $token; ?>" placeholder="<?php echo Minz_Translate::t('blank_to_disable'); ?>"/>
+ <input type="text" id="token" name="token" value="<?php echo $token; ?>" placeholder="<?php echo Minz_Translate::t('blank_to_disable'); ?>"<?php
+ echo Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> />
<?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('explain_token', Minz_Url::display(null, 'html', true), $token); ?>
</div>
</div>
@@ -92,8 +84,6 @@
<button type="reset" class="btn"><?php echo Minz_Translate::t('cancel'); ?></button>
</div>
</div>
-
- <?php } ?>
</form>
<form method="post" action="<?php echo _url('users', 'delete'); ?>">
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php
index 433992e0d..72e2cedc0 100644
--- a/lib/Minz/Configuration.php
+++ b/lib/Minz/Configuration.php
@@ -113,7 +113,7 @@ class Minz_Configuration {
}
public static function _allowAnonymous($allow = false) {
- self::$allow_anonymous = (bool)$allow;
+ self::$allow_anonymous = ((bool)$allow) && self::canLogIn();
}
public static function _authType($value) {
$value = strtolower($value);
@@ -125,6 +125,7 @@ class Minz_Configuration {
self::$auth_type = $value;
break;
}
+ self::_allowAnonymous(self::$allow_anonymous);
}
/**
@@ -252,12 +253,12 @@ class Minz_Configuration {
if (isset ($general['default_user'])) {
self::$default_user = $general['default_user'];
}
- if (isset ($general['allow_anonymous'])) {
- self::$allow_anonymous = ((bool)($general['allow_anonymous'])) && ($general['allow_anonymous'] !== 'no');
- }
if (isset ($general['auth_type'])) {
self::_authType($general['auth_type']);
}
+ if (isset ($general['allow_anonymous'])) {
+ self::$allow_anonymous = ((bool)($general['allow_anonymous'])) && ($general['allow_anonymous'] !== 'no');
+ }
// Base de données
if (isset ($ini_array['db'])) {