-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.php
41 lines (32 loc) · 1005 Bytes
/
verify.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
41
<?php
use Delight\Auth\Auth;
include_once('conn/db.php');
require __DIR__ . '/vendor/autoload.php';
if(isset($_SESSION['email'])){
header("Location: index.php");
}
$auth = new Auth($db);
// Retrieve the selector and token from the URL parameters
$selector = $_GET['selector'] ?? '';
$token = $_GET['token'] ?? '';
try {
$auth->confirmEmail($selector, $token);
$successCode = 1;
} catch (\Delight\Auth\InvalidSelectorTokenPairException $e) {
$errorCode = 2;
} catch (\Delight\Auth\TokenExpiredException $e) {
$errorCode = 3;
} catch (\Delight\Auth\UserAlreadyExistsException $e) {
$errorCode = 4;
} catch (\Delight\Auth\TooManyRequestsException $e) {
$errorCode = 5;
}
// Redirect to login page with error or success code
if (isset($errorCode)) {
header("Location: http://localhost/main/login.php?error=" . $errorCode);
exit();
}
if (isset($successCode)) {
header("Location: http://localhost/main/login.php?success=" . $successCode);
exit();
}