aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/ilias_auth.php
blob: fd642dc14c35fab4d534e4b027b680b6a75d4f3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
# Lifter007: TEST

/**
 * ilias_auth.php - authenticate ILIAS user 
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * @author      Arne Schroeder <schroeder@data-quest.de>
 * @copyright   2018 Suchi & Berg GmbH <info@data-quest.de>
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 */

class IliasAuthController extends StudipController
{

    /**
     * common tasks for all actions
     */
    public function before_filter (&$action, &$args)
    {
        parent::before_filter($action, $args);
    }

    /**
     * check authentication
     */
    public function authenticate_action()
    {
        $authenticated = false;
        $auth_status = StudipAuthAbstract::checkAuthentication(Request::get('login'), Request::get('password'));
        if ($auth_status['uid']) {
            $authenticated = true;
        }
        $query = "SELECT external_user_token_valid_until FROM auth_extern WHERE external_user_name = ? AND external_user_token = ?";
        $result = DBManager::get()->fetchOne($query, [Request::get('login'), Request::get('password')]);
        if (count($result)) {
            if ($result['external_user_token_valid_until'] > time()) {
                $authenticated = true;
            }
        }
        if ($authenticated) {
            $this->render_text('authenticated');
        } else {
            $this->render_nothing();
        }
    }
}