summaryrefslogtreecommitdiff
path: root/src/application/actions/auth/post.php
blob: e9b513812c1ef4131977944088fa1bda7696b31a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

use mystic\forum\orm\User;
use mystic\forum\utils\RequestUtils;

$formId = "login";
$username = RequestUtils::getRequiredField("username", $formId);
$password = RequestUtils::getRequiredField("password", $formId);

$user = new User();
$user->name = $username;
if (!$db->fetchWhere($user, "name") || !password_verify($password, $user->passwordHash)) {
    RequestUtils::triggerFormError(__("Username or password incorrect!"), $formId);
}

if (!$user->activated) {
    RequestUtils::triggerFormError(__("Please activate your user account first!"), $formId);
}

RequestUtils::setAuthorizedUser($user);
header("Location: " . ($_GET["next"] ?? "."));