summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2012-03-01 14:06:03 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2012-03-01 14:06:03 -0500
commit40e8484a5794c21abab52fa30a34a2d013769602 (patch)
treedf8a977e82ce5b96e97ddbf1deec4470d182e381
parent55ed43c3320689297f53e5a9cafc9e766aea3517 (diff)
downloadampache-40e8484a5794c21abab52fa30a34a2d013769602.tar.gz
ampache-40e8484a5794c21abab52fa30a34a2d013769602.tar.bz2
ampache-40e8484a5794c21abab52fa30a34a2d013769602.zip
FS#213 - User Registration
Add an option to have newly registered accounts disabled by default.
-rw-r--r--config/ampache.cfg.php.dist6
-rwxr-xr-xdocs/CHANGELOG1
-rw-r--r--lib/class/user.class.php12
-rw-r--r--register.php3
4 files changed, 17 insertions, 5 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist
index 037e701f..eefb6668 100644
--- a/config/ampache.cfg.php.dist
+++ b/config/ampache.cfg.php.dist
@@ -473,6 +473,12 @@ refresh_limit = "60"
; DEFAULT: false
;admin_notify_reg = "false"
+; This setting determines whether the user will be created as a disabled user.
+; If this is on, an administrator will need to manually enable the account
+; before it's usable.
+; DEFAULT: false
+;admin_enable_required = "false"
+
; This setting will allow all registrants/ldap/http users
; to be auto-approved as a user. By default, they will be
; added as a guest and must be promoted by the admin.
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 9c9747f4..ee709d30 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,7 @@
--------------------------------------------------------------------------
v.3.6-Alpha2
+ - Added admin_enable_required option to user registration
- Fixed session issue preventing some users from streaming
(reported by miir01)
- Quote Content-Disposition header for art, fixes Chrome issue
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index edeefc40..84fb700e 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -642,18 +642,22 @@ class User extends database_object {
* create
* inserts a new user into ampache
*/
- public static function create($username, $fullname, $email, $password, $access) {
+ public static function create($username, $fullname, $email, $password, $access, $disabled = false) {
/* Lets clean up the fields... */
$username = Dba::escape($username);
$fullname = Dba::escape($fullname);
$email = Dba::escape($email);
$access = Dba::escape($access);
- $password_hashed = hash('sha256', $password);
+ $password = hash('sha256', $password);
+ $disabled = $disabled ? 1 : 0;
/* Now Insert this new user */
- $sql = "INSERT INTO `user` (`username`, `fullname`, `email`, `password`, `access`, `create_date`) VALUES" .
- " ('$username','$fullname','$email','$password_hashed','$access','" . time() ."')";
+ $sql = "INSERT INTO `user` (`username`, `disabled`, " .
+ "`fullname`, `email`, `password`, `access`, " .
+ "`create_date`)" .
+ "VALUES('$username', '$disabled', '$fullname', " .
+ "'$email', '$password', '$access', '" . time() ."')";
$db_results = Dba::write($sql);
if (!$db_results) { return false; }
diff --git a/register.php b/register.php
index 010cc2dc..10f4a3d5 100644
--- a/register.php
+++ b/register.php
@@ -160,7 +160,8 @@ switch ($_REQUEST['action']) {
} // auto-user level
- $new_user = User::create($username,$fullname,$email,$pass1,$access);
+ $new_user = User::create($username, $fullname, $email, $pass1,
+ $access, Config::get('admin_enable_required'));
if (!$new_user) {
Error::add('duplicate_user',_("Error: Insert Failed"));