コード例 #1
0
ファイル: handler.php プロジェクト: AlexanderBrevig/OS.js-v2
 public static function login(array $arguments)
 {
     $db = self::_initDB();
     unset($_SESSION['user']);
     $q = "SELECT `id`, `username`, `name`, `groups`, `settings` FROM `users` WHERE `username` = ? AND `password` = ? LIMIT 1;";
     $a = array($arguments['username'], $arguments['password']);
     $response = false;
     if ($stmt = $db->prepare($q)) {
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
         if ($stmt->execute($a)) {
             if ($row = $stmt->fetch()) {
                 $response = array("userData" => array("id" => (int) $row['id'], "username" => $row['username'], "name" => $row['name'], "groups" => (array) json_decode($row['groups'])), "userSettings" => (array) json_decode($row['settings']));
                 if (!$response['userData']['groups']) {
                     $response['userData']['groups'] = array();
                 }
                 if (!$response['userSettings']) {
                     $response['userSettings'] = null;
                 }
             } else {
                 throw new Exception("Invalid login credentials");
             }
         }
     }
     if ($response) {
         $settings = Settings::get();
         $user = APIUser::login($response["userData"]);
         $homedir = sprintf("%s/%s", $settings['vfs']['homes'], $user->getUsername());
         if (!file_exists($homedir)) {
             @mkdir($homedir);
             @mkdir("{$homedir}/.packages");
         }
     }
     return array(false, $response);
 }
コード例 #2
0
ファイル: php.php プロジェクト: genecyber/OS.js-v2
 public static function login(array $arguments)
 {
     $user = APIUser::login(array("id" => 0, "username" => "test", "name" => "EXAMPLE handler user", "groups" => array("admin")));
     return array(false, $user->getData());
 }
コード例 #3
0
ファイル: handler.php プロジェクト: MicroBlocks/OS.js
 public static function login(array $arguments)
 {
     $user = APIUser::login(array("id" => 0, "username" => "demo", "name" => "Demo User", "groups" => array("admin")));
     return array(false, $user->getData());
 }