Explorar el Código

Implémente sélecteur de méthode d’authentification

Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126
Alexandre Alapetite hace 12 años
padre
commit
220341b406

+ 5 - 2
app/Controllers/configureController.php

@@ -326,10 +326,13 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 			Minz_Session::_param('mail', $this->view->conf->mail_login);
 
 			if (Minz_Configuration::isAdmin()) {
-				$anon = (Minz_Request::param('anon_access', false));
+				$anon = Minz_Request::param('anon_access', false);
 				$anon = ((bool)$anon) && ($anon !== 'no');
-				if ($anon != Minz_Configuration::allowAnonymous()) {
+				$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);
 					$ok &= Minz_Configuration::writeFile();
 				}
 			}

+ 3 - 4
app/views/configure/users.phtml

@@ -60,11 +60,10 @@
 			<label class="group-name" for="auth_type"><?php echo Minz_Translate::t('auth_type'); ?></label>
 			<div class="group-controls">
 				<select id="auth_type" name="auth_type">
-					<option value="none">None (dangerous)</option>
-					<option value="http_auth">HTTP Auth</option>
-					<option value="persona">Mozilla Persona</option>
+					<option value="none"<?php echo Minz_Configuration::authType() === 'none' ? ' selected="selected"' : ''; ?>>None (dangerous)</option>
+					<option value="http_auth"<?php echo Minz_Configuration::authType() === 'http_auth' ? ' selected="selected"' : ''; ?>>HTTP Auth</option>
+					<option value="persona"<?php echo Minz_Configuration::authType() === 'persona' ? ' selected="selected"' : ''; ?>>Mozilla Persona</option>
 				</select>
-				(selector not implemented yet)
 			</div>
 		</div>
 

+ 19 - 0
lib/Minz/Configuration.php

@@ -53,6 +53,7 @@ class Minz_Configuration {
 	private static $default_user = '';
 	private static $current_user = '';
 	private static $allow_anonymous = false;
+	private static $auth_type = 'none';
 
 	private static $db = array (
 		'host' => false,
@@ -103,9 +104,23 @@ class Minz_Configuration {
 	public static function allowAnonymous() {
 		return self::$allow_anonymous;
 	}
+	public static function authType() {
+		return self::$auth_type;
+	}
+
 	public static function _allowAnonymous($allow = false) {
 		self::$allow_anonymous = (bool)$allow;
 	}
+	public static function _authType($value) {
+		$value = strtolower($value);
+		switch ($value) {
+			case 'none':
+			case 'http_auth':
+			case 'persona':
+				self::$auth_type = $value;
+				break;
+		}
+	}
 
 	/**
 	 * Initialise les variables de configuration
@@ -133,6 +148,7 @@ class Minz_Configuration {
 				'title' => self::$title,
 				'default_user' => self::$default_user,
 				'allow_anonymous' => self::$allow_anonymous,
+				'auth_type' => self::$auth_type,
 			),
 			'db' => self::$db,
 		);
@@ -234,6 +250,9 @@ class Minz_Configuration {
 		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']);
+		}
 
 		// Base de données
 		$db = false;