-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate.php
40 lines (34 loc) · 1.36 KB
/
activate.php
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
<?php
require_once("./bootstrap/autoload.php");
if(Forms::isGet()){
$email = Url::getParam("email");
$hash = Url::getParam("activation_code");
if(!Forms::checkIfEmpty(array($email, $hash)))
{
$_SESSION["msg"]["errors"] = "Empty parameters passed";
Helper::redirectTo(3, SITE_URL."/register.php");
} else {
if(!Forms::isEmail($email)){
echo "invalid email address passed";
} else {
$accountObj = new Users();
$user = $accountObj->fetchUnverifiedUser($hash, $email);
if($user && (int)$user["isActive"] === 0)
{
if($accountObj->makeActive($user["id"])){
$_SESSION["msg"]["success"] = "Your account has been successfully activated! login here";
Helper::redirectTo(3, SITE_URL."/login.php");
} else {
$_SESSION["msg"]["error"] = "Invalid activation link! please register again.";
Helper::redirectTo(3, SITE_URL."/register.php");
}
} else {
$_SESSION["msg"]["error"] = "Your account was already activated, please contact administrator if you have any challenges";
Helper::redirectTo(3, SITE_URL."/login.php");
}
}
}
} else {
Helper::redirectTo(3, SITE_URL."/register.php");
}
?>