2010-07-15 12:09:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ownCloud
|
|
|
|
*
|
|
|
|
* @author Frank Karlitschek
|
|
|
|
* @copyright 2010 Frank Karlitschek karlitschek@kde.org
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-07-15 17:10:20 +00:00
|
|
|
|
2010-07-15 12:09:22 +00:00
|
|
|
/**
|
|
|
|
* Class for usermanagement in a SQL Database
|
|
|
|
* eg mysql, sqlite
|
|
|
|
*/
|
|
|
|
class OC_USER_MOD_AUTH extends OC_USER {
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* check if the login button is pressed and logg the user in
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function loginLisener() {
|
|
|
|
return '';
|
2010-07-15 12:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* try to create a new user
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function createUser($username, $password) {
|
2010-07-15 12:09:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* try to login a user
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function login($username, $password) {
|
|
|
|
if ( isset($_SERVER['PHP_AUTH_USER']) AND ('' !== $_SERVER['PHP_AUTH_USER']) ) {
|
|
|
|
$_SESSION['user_id'] = $_SERVER['PHP_AUTH_USER'];
|
|
|
|
$_SESSION['username'] = $_SERVER['PHP_AUTH_USER'];
|
|
|
|
$_SESSION['username_clean'] = $_SERVER['PHP_AUTH_USER'];
|
|
|
|
|
2010-07-15 12:09:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-07-15 17:10:20 +00:00
|
|
|
|
2010-07-15 12:09:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* check if the logout button is pressed and logout the user
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function logoutLisener() {
|
|
|
|
if( isset($_GET['logoutbutton']) AND isset($_SESSION['username']) ) {
|
2010-07-15 12:09:22 +00:00
|
|
|
header('WWW-Authenticate: Basic realm="ownCloud"');
|
|
|
|
header('HTTP/1.0 401 Unauthorized');
|
|
|
|
die('401 Unauthorized');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* check if a user is logged in
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function isLoggedIn() {
|
|
|
|
if ( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ) {
|
2010-07-15 12:09:22 +00:00
|
|
|
return true;
|
2010-07-15 17:10:20 +00:00
|
|
|
} else {
|
|
|
|
if ( isset($_SERVER['PHP_AUTH_USER']) AND ('' !== $_SERVER['PHP_AUTH_USER']) ) {
|
|
|
|
$_SESSION['user_id'] = $_SERVER['PHP_AUTH_USER'];
|
|
|
|
$_SESSION['username'] = $_SERVER['PHP_AUTH_USER'];
|
|
|
|
$_SESSION['username_clean'] = $_SERVER['PHP_AUTH_USER'];
|
|
|
|
|
2010-07-15 12:09:22 +00:00
|
|
|
return true;;
|
|
|
|
}
|
|
|
|
}
|
2010-07-15 17:10:20 +00:00
|
|
|
|
2010-07-15 12:09:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* try to create a new group
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function createGroup($groupname) {
|
2010-07-15 12:09:22 +00:00
|
|
|
// does not work with MOD_AUTH (only or some modules)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* get the id of a user
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function getUserId($username, $nocache=false) {
|
2010-07-15 12:09:22 +00:00
|
|
|
// does not work with MOD_AUTH (only or some modules)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* get the id of a group
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function getGroupId($groupname, $nocache=false) {
|
2010-07-15 12:09:22 +00:00
|
|
|
// does not work with MOD_AUTH (only or some modules)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* get the name of a group
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function getGroupName($groupid, $nocache=false) {
|
2010-07-15 12:09:22 +00:00
|
|
|
// does not work with MOD_AUTH (only or some modules)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* check if a user belongs to a group
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function inGroup($username, $groupname) {
|
2010-07-15 12:09:22 +00:00
|
|
|
// does not work with MOD_AUTH (only or some modules)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* add a user to a group
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function addToGroup($username, $groupname) {
|
2010-07-15 12:09:22 +00:00
|
|
|
// does not work with MOD_AUTH (only or some modules)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-07-15 17:10:20 +00:00
|
|
|
public static function generatePassword() {
|
2010-07-15 12:09:22 +00:00
|
|
|
return uniqid();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* get all groups the user belongs to
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function getUserGroups($username) {
|
2010-07-15 12:09:22 +00:00
|
|
|
// does not work with MOD_AUTH (only or some modules)
|
2010-07-15 17:10:20 +00:00
|
|
|
$groups = array();
|
2010-07-15 12:09:22 +00:00
|
|
|
return $groups;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* set the password of a user
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function setPassword($username, $password) {
|
2010-07-15 12:09:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 17:10:20 +00:00
|
|
|
* check the password of a user
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function checkPassword($username, $password) {
|
2010-07-15 12:09:22 +00:00
|
|
|
// does not work with MOD_AUTH (only or some modules)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|