1
0
mirror of https://github.com/moparisthebest/user_sql synced 2024-11-26 02:52:21 -05:00

Enable password change in web interface

This commit is contained in:
Andreas Boehler 2012-12-06 14:16:35 +01:00
parent 6113d52822
commit 39a19ae043

View File

@ -36,7 +36,8 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
protected $db_conn; protected $db_conn;
protected $db; protected $db;
public function __construct() { public function __construct()
{
$this->db_conn = false; $this->db_conn = false;
$this->sql_host = OCP\Config::getAppValue('user_sql', 'sql_host', ''); $this->sql_host = OCP\Config::getAppValue('user_sql', 'sql_host', '');
$this->sql_username = OCP\Config::getAppValue('user_sql', 'sql_user', ''); $this->sql_username = OCP\Config::getAppValue('user_sql', 'sql_user', '');
@ -60,7 +61,8 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
return false; return false;
} }
public function implementsAction($actions) { public function implementsAction($actions)
{
return (bool)((OC_USER_BACKEND_CHECK_PASSWORD) & $actions); return (bool)((OC_USER_BACKEND_CHECK_PASSWORD) & $actions);
} }
@ -70,16 +72,27 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
return false; return false;
} }
public function deleteUser( $uid ) { public function deleteUser( $uid )
{
// Can't delete user // Can't delete user
OC_Log::write('OC_USER_SQL', 'Not possible to delete local users from web frontend using SQL user backend', OC_Log::ERROR); OC_Log::write('OC_USER_SQL', 'Not possible to delete local users from web frontend using SQL user backend', OC_Log::ERROR);
return false; return false;
} }
public function setPassword ( $uid, $password ) { public function setPassword ( $uid, $password ) {
// We can't change user password // Update the user's password - this might affect other services, that user the same database, as well
OC_Log::write('OC_USER_SQL', 'Not possible to change password for local users from web frontend using SQL user backend', OC_Log::ERROR); if(!this->db_conn)
return false; {
return false;
}
$query = "UPDATE $this->sql_table SET $this->sql_column_password = ENCRYPT('$password') WHERE $sql_column_username = '$uid'";
$result = $this->db->prepare($query);
if(!$result->execute())
{
return false;
}
return true;
} }
/** /**
@ -127,7 +140,8 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
* Get a list of all users. * Get a list of all users.
*/ */
public function getUsers($search = '', $limit = null, $offset = null){ public function getUsers($search = '', $limit = null, $offset = null)
{
$users = array(); $users = array();
if(!$this->db_conn) if(!$this->db_conn)
{ {