/**
  * Test login
  */
 public function login($uid)
 {
     $login = TaskerMAN\Application\Login::verifyCredentials($this->email, $this->password);
     $this->assertInstanceOf('TaskerMAN\\Application\\User', $login);
     // Verify it's returning the correct stuff
     $this->assertEquals($login->getID(), $uid);
     $this->assertEquals($login->getEmail(), $this->email);
     $this->assertEquals($login->getName(), $this->name);
     $this->assertEquals($login->isAdmin(), $this->admin);
     // Check API key is valid
     $API = TaskerMAN\Application\API::authenticateByToken($login->getAPIToken());
     $this->assertTrue($API);
 }
예제 #2
0
<?php

// Get username and password
$email = TaskerMAN\Core\IO::GET('email');
$password = TaskerMAN\Core\IO::GET('password');
if (empty($email) || empty($password)) {
    throw new TaskerMAN\Application\APIErrorException('Requires email and password');
}
// Verify the user's login credentials
$user = TaskerMAN\Application\Login::verifyCredentials($email, $password);
// Login details incorrect
if (!$user) {
    throw new TaskerMAN\Application\APIErrorException('Incorrect email or password');
}
// Login success, return API Token
echo TaskerMAN\Application\API::response(array('key' => $user->api_token));
예제 #3
0
 /**
  * Test a set of login credentials
  */
 public function testLogin()
 {
     $login = TaskerMAN\Application\Login::verifyCredentials('*****@*****.**', 'monaghan!');
     $this->assertInstanceOf('TaskerMAN\\Application\\User', $login);
 }
예제 #4
0
// Check if the application is installed, if not, bounce to install page
if (TaskerMAN\Core\Install::required()) {
    header('Location: index.php?p=install');
    exit;
}
// If user is already logged in, take them to main dashboard
if (TaskerMAN\WebInterface\Session::isLoggedIn()) {
    header('Location: index.php?p=main');
    exit;
}
// Hide template
TaskerMAN\WebInterface\WebInterface::showTemplate(false);
$error = null;
if (isset($_POST['submit'])) {
    $user = TaskerMAN\Application\Login::verifyCredentials(TaskerMAN\Core\IO::POST('email'), TaskerMAN\Core\IO::POST('password'));
    if (!$user) {
        // Login failed
        $error = '<span style="align: center; color: red">Invalid username or password combination</span>';
    } elseif (!$user->admin) {
        $error = '<span style="align: center; color: red">Your account does not have access to this control panel</span>';
    } else {
        TaskerMAN\WebInterface\Session::set('uid', $user->id);
        header('Location: index.php?p=main');
        exit;
    }
}
?>

<!DOCTYPE html>
<html lang="en">