-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathForceUserLogin.php
More file actions
27 lines (24 loc) · 880 Bytes
/
Copy pathForceUserLogin.php
File metadata and controls
27 lines (24 loc) · 880 Bytes
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
<?php
/**
* Forces users to login before accessing any page in WHMCS.
*
* @package WHMCS
* @author Dennis Hermannsen <hej@dennishermannsen.dk>
*/
use WHMCS\Authentication\CurrentUser;
use WHMCS\Config\Setting;
add_hook('ClientAreaPage', 1, function ($vars) {
$user = new CurrentUser;
$templateFile = $vars['templatefile'];
$excludedTemplateFiles = ['login', 'dologin', 'password-reset-container', 'register', 'clientarea', 'user-invite-accept'];
if(!$user->isAuthenticatedUser() and !$user->isAuthenticatedAdmin() and !in_array($templateFile, $excludedTemplateFiles))
{
$systemURL = Setting::where('setting', 'SystemURL')->first();
$systemURL = $systemURL->value;
if(!str_ends_with($systemURL, '/')){
$systemURL = $systemURL.'/';
}
header("Location: {$systemURL}login.php");
exit();
}
});