This repository was archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivate.php
48 lines (45 loc) · 1.53 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
41
42
43
44
45
46
47
48
<?php
use \Sizzle\Bacon\Database\{
Organization,
RecruitingToken,
User,
UserMilestone
};
$type = strtolower($_GET['type'] ?? '');
// activate user
$user = new User($_GET['uid'] ?? 0);
if (isset($user->email_address) && $user->activate($_GET['key'] ?? '')) {
$_SESSION['activation_key'] = $_GET['key'];
$_SESSION['email'] = $user->email_address;
} else {
$type = 'fail';
}
switch ($type) {
case 'emailtoken':
// set session variable of user token
$tokens = (new RecruitingToken())->getUserTokens($user->id);
$_SESSION['first_token'] = $tokens[0]->long_id;
$message = 'Please create a password to view your token.';
case 'nopassword':
// show create password page
$message = $message ?? 'Please set a password before logging in.';
require_once __DIR__.'/password_set.php';
break;
case '':
// web only activation where user's already set up password
$_SESSION['user_id'] = $user->id;
$_SESSION['admin'] = $user->admin;
$_SESSION['app_root'] = '/';
$_SESSION['app_url'] = APP_URL;
$_SESSION['email'] = $user->email_address;
if (isset($user->stripe_id)) {
$_SESSION['stripe_id'] = $user->stripe_id;
} elseif (isset($user->organization_id)) {
$org = new Organization($user->organization_id);
$paying_user = new User($org->paying_user ?? NULL);
$_SESSION['stripe_id'] = $paying_user->stripe_id ?? NULL;
}
$UserMilestone = new UserMilestone($user->id, 'Log In');
default:
header('Location: '.'/'.'?action=login');
}