diff options
Diffstat (limited to 'application/models')
-rw-r--r-- | application/models/muser.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/application/models/muser.php b/application/models/muser.php index e0994cfa6..29c5a453f 100644 --- a/application/models/muser.php +++ b/application/models/muser.php @@ -18,6 +18,27 @@ class Muser extends CI_Model { $this->load->helper("filebin"); $this->load->driver("duser"); + + if (is_cli_client()) { + $username = $this->input->post("username"); + $password = $this->input->post("password"); + + // prefer post parameters if either (username or password) is set + if ($username === false && $password === false) { + if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { + $username = $_SERVER['PHP_AUTH_USER']; + $password = $_SERVER['PHP_AUTH_PW']; + } + } + + if ($username !== false && $password !== false) { + if (!$this->login($username, $password)) { + // TODO: better message + echo "login failed.\n"; + exit; + } + } + } } function has_session() |