config: add AUTO_ADD_USER (closes #294)

This commit is contained in:
Andrew Dolgov 2011-04-12 19:28:35 +04:00
parent 388c645a8b
commit 42315f8de8
3 changed files with 37 additions and 2 deletions

View File

@ -140,6 +140,11 @@
// Otherwise users will be redirected to login form with their login // Otherwise users will be redirected to login form with their login
// information pre-filled. // information pre-filled.
define('AUTO_CREATE_USER', false);
// If users are authenticated by your web server, set this to true if
// You want new users to be automaticaly created in tt-rss database
// on first login
define('LOCK_DIRECTORY', 'lock'); define('LOCK_DIRECTORY', 'lock');
// Directory for lockfiles, must be writable to the user you run // Directory for lockfiles, must be writable to the user you run
// daemon process or cronjobs under. // daemon process or cronjobs under.

View File

@ -1892,6 +1892,19 @@
FROM ttrss_users WHERE FROM ttrss_users WHERE
login = '$login'"; login = '$login'";
if (defined('AUTO_CREATE_USER') && AUTO_CREATE_USER
&& $_SERVER["REMOTE_USER"]) {
$result = db_query($link, $query);
// First login ?
if (db_num_rows($result) == 0) {
$query = "INSERT INTO ttrss_users
(login,access_level,last_login,created)
VALUES ('$login', 0, null, NOW())";
db_query($link, $query);
}
}
} else { } else {
$query = "SELECT id,login,access_level,pwd_hash $query = "SELECT id,login,access_level,pwd_hash
FROM ttrss_users WHERE FROM ttrss_users WHERE
@ -1909,6 +1922,23 @@
db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " . db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
$_SESSION["uid"]); $_SESSION["uid"]);
// LemonLDAP can send user informations via HTTP HEADER
if (defined('AUTO_CREATE_USER') && AUTO_CREATE_USER){
// update user name
if ($_SERVER['HTTP_USER_NAME']){
$fullname = db_escape_string($_SERVER['HTTP_USER_NAME']);
db_query($link, "UPDATE ttrss_users SET full_name = '$fullname' WHERE id = " .
$_SESSION["uid"]);
}
// update user mail
if ($_SERVER['HTTP_USER_MAIL']){
$email = db_escape_string($_SERVER['HTTP_USER_MAIL']);
db_query($link, "UPDATE ttrss_users SET email = '$email' WHERE id = " .
$_SESSION["uid"]);
}
}
$_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"]; $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
$_SESSION["pwd_hash"] = db_fetch_result($result, 0, "pwd_hash"); $_SESSION["pwd_hash"] = db_fetch_result($result, 0, "pwd_hash");

View File

@ -1,3 +1,3 @@
<?php # This file has been generated at: Fri Apr 1 20:41:16 MSD 2011 <?php # This file has been generated at: Tue Apr 12 19:27:00 MSD 2011
define('GENERATED_CONFIG_CHECK', 22); define('GENERATED_CONFIG_CHECK', 22);
$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'SELF_URL_PATH', 'MAGPIE_FETCH_TIME_OUT', 'MAGPIE_CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'SINGLE_USER_MODE', 'TMP_DIRECTORY', 'ENABLE_UPDATE_DAEMON', 'DAEMON_SLEEP_INTERVAL', 'DATABASE_BACKED_SESSIONS', 'SESSION_CHECK_ADDRESS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'DAEMON_UPDATE_LOGIN_LIMIT', 'CHECK_FOR_NEW_VERSION', 'DIGEST_ENABLE', 'DIGEST_EMAIL_LIMIT', 'DAEMON_SENDS_DIGESTS', 'MYSQL_CHARSET', 'DEFAULT_UPDATE_METHOD', 'SIMPLEPIE_CACHE_DIR', 'SIMPLEPIE_CACHE_IMAGES', 'COUNTERS_MAX_AGE', 'DIGEST_FROM_NAME', 'DIGEST_FROM_ADDRESS', 'DIGEST_SUBJECT', 'DIGEST_SMTP_HOST', 'DIGEST_SMTP_LOGIN', 'DIGEST_SMTP_PASSWORD', 'DAEMON_FEED_LIMIT', 'ALLOW_REMOTE_USER_AUTH', 'AUTO_LOGIN', 'LOCK_DIRECTORY', 'ENABLE_GZIP_OUTPUT', 'PHP_EXECUTABLE', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'FEEDBACK_URL', 'FORCE_ARTICLE_PURGE', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ENABLE_TWEET_BUTTON', 'CONSUMER_KEY', 'CONSUMER_SECRET', 'PUBSUBHUBBUB_HUB', 'ISCONFIGURED', 'CONFIG_VERSION'); ?> $requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'SELF_URL_PATH', 'MAGPIE_FETCH_TIME_OUT', 'MAGPIE_CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'SINGLE_USER_MODE', 'TMP_DIRECTORY', 'ENABLE_UPDATE_DAEMON', 'DAEMON_SLEEP_INTERVAL', 'DATABASE_BACKED_SESSIONS', 'SESSION_CHECK_ADDRESS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'DAEMON_UPDATE_LOGIN_LIMIT', 'CHECK_FOR_NEW_VERSION', 'DIGEST_ENABLE', 'DIGEST_EMAIL_LIMIT', 'DAEMON_SENDS_DIGESTS', 'MYSQL_CHARSET', 'DEFAULT_UPDATE_METHOD', 'SIMPLEPIE_CACHE_DIR', 'SIMPLEPIE_CACHE_IMAGES', 'COUNTERS_MAX_AGE', 'DIGEST_FROM_NAME', 'DIGEST_FROM_ADDRESS', 'DIGEST_SUBJECT', 'DIGEST_SMTP_HOST', 'DIGEST_SMTP_LOGIN', 'DIGEST_SMTP_PASSWORD', 'DAEMON_FEED_LIMIT', 'ALLOW_REMOTE_USER_AUTH', 'AUTO_LOGIN', 'AUTO_CREATE_USER', 'LOCK_DIRECTORY', 'ENABLE_GZIP_OUTPUT', 'PHP_EXECUTABLE', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'FEEDBACK_URL', 'FORCE_ARTICLE_PURGE', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ENABLE_TWEET_BUTTON', 'CONSUMER_KEY', 'CONSUMER_SECRET', 'PUBSUBHUBBUB_HUB', 'ISCONFIGURED', 'CONFIG_VERSION'); ?>