summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-08-11 12:55:19 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-08-11 14:49:30 +0200
commitf71d39467f353ae5f67984c0809bbda5ff7968b0 (patch)
tree7d3bc34112ea3e10d413db3b662f66e762e3d914
parenta147f1c43beb242af3d54f07ca32e88c5ffc5d8e (diff)
Remove api keys dependency on username
We don't need it and getting the user name from the user drivers is way more complicated. Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--application/helpers/filebin_helper.php6
-rw-r--r--application/models/muser.php7
-rw-r--r--application/views/file/upload_form.php2
-rw-r--r--application/views/header.php4
4 files changed, 11 insertions, 8 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php
index 88bb290c4..4af106a14 100644
--- a/application/helpers/filebin_helper.php
+++ b/application/helpers/filebin_helper.php
@@ -323,6 +323,12 @@ function auth_driver_function_implemented($function)
return $result[$function];
}
+function user_logged_in()
+{
+ $CI =& get_instance();
+ return $CI->muser->logged_in();
+}
+
function send_json_reply($array)
{
$CI =& get_instance();
diff --git a/application/models/muser.php b/application/models/muser.php
index 312d895e5..843b7cad6 100644
--- a/application/models/muser.php
+++ b/application/models/muser.php
@@ -97,18 +97,15 @@ class Muser extends CI_Model {
{
$this->require_session();
- // FIXME: get username/id from duser or move them to apikeys table
- // (users is empty when using any other driver than duser_db)
$query = $this->db->query("
- SELECT a.user userid, u.username
+ SELECT a.user userid
FROM apikeys a
- JOIN users u on a.user = u.id
WHERE a.key = ?
", array($apikey))->row_array();
if (isset($query["userid"])) {
$this->session->set_userdata('logged_in', true);
- $this->session->set_userdata('username', $query["username"]);
+ $this->session->set_userdata('username', "");
$this->session->set_userdata('userid', $query["userid"]);
$this->session->set_userdata('access_level', 'apikey');
return true;
diff --git a/application/views/file/upload_form.php b/application/views/file/upload_form.php
index 99c1d9e42..841ac3746 100644
--- a/application/views/file/upload_form.php
+++ b/application/views/file/upload_form.php
@@ -1,4 +1,4 @@
-<?php if (isset($username) && $username) { ?>
+<?php if (user_logged_in()) { ?>
<div class="well">
<div class="row-fluid">
<div class="span12 text-upload-form">
diff --git a/application/views/header.php b/application/views/header.php
index e85463735..ba6d6ae9d 100644
--- a/application/views/header.php
+++ b/application/views/header.php
@@ -45,7 +45,7 @@ if (is_cli_client() && !isset($force_full_html)) {
</a>
<?php if(!isset($GLOBALS["is_error_page"])) { ?>
<ul class="nav pull-right">
- <?php if(isset($username) && $username) { ?>
+ <?php if(user_logged_in()) { ?>
<li><a href="<?php echo site_url("/user/logout"); ?>">Logout</a></li>
<?php } else { ?>
<li class="dropdown">
@@ -65,7 +65,7 @@ if (is_cli_client() && !isset($force_full_html)) {
</ul>
<?php }; ?>
<ul class="nav">
- <?php if(isset($username) && $username) { ?>
+ <?php if(user_logged_in()) { ?>
<li><a href="<?php echo site_url("file/index") ?>"><i class="icon-pencil icon-white"></i> New</a></li>
<li><a href="<?php echo site_url("file/upload_history") ?>"><i class="icon-book icon-white"></i> History</a></li>
<li class="dropdown">