aboutsummaryrefslogtreecommitdiff
path: root/app/FreshRSS.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-30 01:03:32 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-30 01:03:32 +0100
commit92efd68a3a13e49fe7bbfb8441611c0dcd639415 (patch)
treee6228848744b9369ad4e4e52c541075f5c723b6d /app/FreshRSS.php
parent220341b40642771f9b5db97296edfb1913182464 (diff)
Début de mode multi-utilisateur avec http_auth
+ Légère optimisation de Minz_View. + Encore plus de tests de bibliothèques dans install.php Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126 et https://github.com/marienfressinaud/FreshRSS/issues/303
Diffstat (limited to 'app/FreshRSS.php')
-rw-r--r--app/FreshRSS.php56
1 files changed, 43 insertions, 13 deletions
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index 05c8ec8e0..10f362717 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -1,26 +1,56 @@
<?php
class FreshRSS extends Minz_FrontController {
- public function init () {
- Minz_Session::init ('FreshRSS');
-
- $this->loadParamsView ();
- $this->loadStylesAndScripts ();
- $this->loadNotifications ();
+ public function init($currentUser = null) {
+ Minz_Session::init('FreshRSS');
+ $this->accessControl($currentUser);
+ $this->loadParamsView();
+ $this->loadStylesAndScripts();
+ $this->loadNotifications();
}
- private function loadParamsView () {
+ private function accessControl($currentUser) {
+ if ($currentUser === null) {
+ switch (Minz_Configuration::authType()) {
+ case 'http_auth':
+ $currentUser = httpAuthUser();
+ $loginOk = $currentUser != '';
+ break;
+ case 'persona':
+ $currentUser = Minz_Configuration::defaultUser();
+ $loginOk = Minz_Session::param('mail') != '';
+ break;
+ case 'none':
+ $currentUser = Minz_Configuration::defaultUser();
+ $loginOk = true;
+ break;
+ default:
+ $loginOk = false;
+ break;
+ }
+ } elseif ((PHP_SAPI === 'cli') && (Minz_Request::actionName() === 'actualize')) { //Command line
+ Minz_Configuration::_authType('none');
+ $loginOk = true;
+ }
+
+ if (!$loginOk || !isValidUser($currentUser)) {
+ $currentUser = Minz_Configuration::defaultUser();
+ $loginOk = false;
+ }
+ Minz_Configuration::_currentUser($currentUser);
+ Minz_View::_param ('loginOk', $loginOk);
+
try {
- $this->conf = new FreshRSS_Configuration();
+ $this->conf = new FreshRSS_Configuration($currentUser);
} catch (Minz_Exception $e) {
// Permission denied or conf file does not exist
- // it's critical!
die($e->getMessage());
}
-
Minz_View::_param ('conf', $this->conf);
+ }
+
+ private function loadParamsView () {
Minz_Session::_param ('language', $this->conf->language);
Minz_Translate::init();
-
$output = Minz_Request::param ('output');
if (!$output) {
$output = $this->conf->view_mode;
@@ -31,12 +61,12 @@ class FreshRSS extends Minz_FrontController {
private function loadStylesAndScripts () {
$theme = FreshRSS_Themes::get_infos($this->conf->theme);
if ($theme) {
- foreach($theme["files"] as $file) {
+ foreach($theme['files'] as $file) {
Minz_View::appendStyle (Minz_Url::display ('/themes/' . $theme['path'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file)));
}
}
- if (login_is_conf ($this->conf)) {
+ if (Minz_Configuration::authType() === 'persona') {
Minz_View::appendScript ('https://login.persona.org/include.js');
}
$includeLazyLoad = $this->conf->lazyload && ($this->conf->display_posts || Minz_Request::param ('output') === 'reader');