<?php

/**
 *  Informatica Eindproject D4p
 *  6in3, Stedelijk Gymnasium Nijmegen
 *  Docent: Hans de Wolf
 *
 *  ==================
 *
 *  Daniel Boutros,
 *  Christiaan Goossens,
 *  Jelmer Hinssen
 */

namespace Inforbank\Application;

use \Slim\App;

class Login
{
    public function __construct(App $app)
    {
        $app->get('/login', function ($request, $response, $args) {
            // Render index view
            return $this->renderer->render($response, 'login.phtml', $args);
        });
        $app->post('/login', function ($request, $response, $args) {
            // Render index view
            $post = $request->getParsedBody();

            try {
                $resp = $this->auth->login($post['rekeningnr'], $post['pascode']);

                if ($resp) {
                    echo "HIER EEN REDIRECT GRAAG";
                } else {
                    echo "ERR PASS!";
                }
            } catch (\Exception $e) {
                echo "ERR REK!";
            }

            die();
        });
    }
}
