mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Pass the settings object to all plugins.
This commit is contained in:
@@ -113,13 +113,9 @@ class authentication {
|
||||
$object->username = $this->username;
|
||||
$object->password = $this->password;
|
||||
}
|
||||
//database plugin requires the authentication object and settings
|
||||
if ($name == 'database') {
|
||||
//initialize the plugin send the authentication object and settings
|
||||
$array = $object->$name($this, $settings);
|
||||
} else {
|
||||
//get the array from the plugin
|
||||
$array = $object->$name();
|
||||
}
|
||||
|
||||
//build a result array
|
||||
if (!empty($array) && is_array($array)) {
|
||||
$result['plugin'] = $array["plugin"];
|
||||
|
||||
@@ -55,17 +55,20 @@ class plugin_email {
|
||||
* time based one time password with email
|
||||
* @return array [authorized] => true or false
|
||||
*/
|
||||
function email() {
|
||||
function email(authentication $auth, settings $settings) {
|
||||
|
||||
//pre-process some settings
|
||||
$settings['theme']['favicon'] = !empty($_SESSION['theme']['favicon']['text']) ? $_SESSION['theme']['favicon']['text'] : PROJECT_PATH.'/themes/default/favicon.ico';
|
||||
$settings['login']['destination'] = !empty($_SESSION['login']['destination']['text']) ? $_SESSION['login']['destination']['text'] : '';
|
||||
$settings['users']['unique'] = !empty($_SESSION['users']['unique']['text']) ? $_SESSION['users']['unique']['text'] : '';
|
||||
$settings['theme']['logo'] = !empty($_SESSION['theme']['logo']['text']) ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH.'/themes/default/images/logo_login.png';
|
||||
$settings['theme']['login_logo_width'] = !empty($_SESSION['theme']['login_logo_width']['text']) ? $_SESSION['theme']['login_logo_width']['text'] : 'auto; max-width: 300px';
|
||||
$settings['theme']['login_logo_height'] = !empty($_SESSION['theme']['login_logo_height']['text']) ? $_SESSION['theme']['login_logo_height']['text'] : 'auto; max-height: 300px';
|
||||
$settings['theme']['message_delay'] = isset($_SESSION['theme']['message_delay']) ? 1000 * (float) $_SESSION['theme']['message_delay'] : 3000;
|
||||
$settings['theme']['background_video'] = isset($_SESSION['theme']['background_video'][0]) ? $_SESSION['theme']['background_video'][0] : null;
|
||||
$theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico');
|
||||
$theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png');
|
||||
$theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px');
|
||||
$theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
|
||||
$theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000);
|
||||
$background_videos = $settings->get('theme', 'background_video', null);
|
||||
$theme_background_video = (isset($background_videos) && is_array($background_videos)) ? $background_videos[0] : null;
|
||||
//$login_domain_name_visible = $settings->get('login', 'domain_name_visible');
|
||||
//$login_domain_name = $settings->get('login', 'domain_name');
|
||||
$login_destination = $settings->get('login', 'destination');
|
||||
$users_unique = $settings->get('users', 'unique', '');
|
||||
|
||||
//get the domain
|
||||
$domain_array = explode(":", $_SERVER["HTTP_HOST"]);
|
||||
@@ -93,16 +96,16 @@ class plugin_email {
|
||||
|
||||
//assign default values to the template
|
||||
$view->assign("project_path", PROJECT_PATH);
|
||||
$view->assign("login_destination_url", $settings['login']['destination']);
|
||||
$view->assign("favicon", $settings['theme']['favicon']);
|
||||
$view->assign("login_destination_url", $login_destination);
|
||||
$view->assign("favicon", $theme_favicon);
|
||||
$view->assign("login_title", $text['label-username']);
|
||||
$view->assign("login_username", $text['label-username']);
|
||||
$view->assign("login_logo_width", $settings['theme']['login_logo_width']);
|
||||
$view->assign("login_logo_height", $settings['theme']['login_logo_height']);
|
||||
$view->assign("login_logo_source", $settings['theme']['logo']);
|
||||
$view->assign("login_logo_width", $theme_login_logo_width);
|
||||
$view->assign("login_logo_height", $theme_login_logo_height);
|
||||
$view->assign("login_logo_source", $theme_logo);
|
||||
$view->assign("button_login", $text['button-login']);
|
||||
$view->assign("message_delay", $settings['theme']['message_delay']);
|
||||
$view->assign("background_video", $settings['theme']['background_video']);
|
||||
$view->assign("message_delay", $theme_message_delay);
|
||||
$view->assign("background_video", $theme_background_video);
|
||||
|
||||
//messages
|
||||
$view->assign('messages', message::html(true, ' '));
|
||||
@@ -129,7 +132,7 @@ class plugin_email {
|
||||
$sql .= " username = :username\n";
|
||||
$sql .= " or user_email = :username\n";
|
||||
$sql .= ")\n";
|
||||
if ($settings['users']['unique'] != "global") {
|
||||
if ($users_unique != "global") {
|
||||
//unique username per domain (not globally unique across system - example: email address)
|
||||
$sql .= "and domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
@@ -330,16 +333,16 @@ class plugin_email {
|
||||
|
||||
//assign default values to the template
|
||||
$view->assign("project_path", PROJECT_PATH);
|
||||
$view->assign("login_destination_url", $settings['login']['destination']);
|
||||
$view->assign("favicon", $settings['theme']['favicon']);
|
||||
$view->assign("login_destination_url", $login_destination);
|
||||
$view->assign("favicon", $theme_favicon);
|
||||
$view->assign("login_title", $text['label-verify']);
|
||||
$view->assign("login_email_description", $text['label-email_description']);
|
||||
$view->assign("login_authentication_code", $text['label-authentication_code']);
|
||||
$view->assign("login_logo_width", $settings['theme']['login_logo_width']);
|
||||
$view->assign("login_logo_height", $settings['theme']['login_logo_height']);
|
||||
$view->assign("login_logo_source", $settings['theme']['logo']);
|
||||
$view->assign("login_logo_width", $theme_login_logo_width);
|
||||
$view->assign("login_logo_height", $theme_login_logo_height);
|
||||
$view->assign("login_logo_source", $theme_logo);
|
||||
$view->assign("button_verify", $text['label-verify']);
|
||||
$view->assign("message_delay", $settings['theme']['message_delay']);
|
||||
$view->assign("message_delay", $theme_message_delay);
|
||||
if (!empty($_SESSION['username'])) {
|
||||
$view->assign("username", $_SESSION['username']);
|
||||
$view->assign("button_cancel", $text['button-cancel']);
|
||||
@@ -377,7 +380,7 @@ class plugin_email {
|
||||
$sql .= " username = :username\n";
|
||||
$sql .= " or user_email = :username\n";
|
||||
$sql .= ")\n";
|
||||
if ($settings['users']['unique'] != "global") {
|
||||
if ($users_unique != "global") {
|
||||
//unique username per domain (not globally unique across system - example: email address)
|
||||
$sql .= "and domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
@@ -431,7 +434,7 @@ class plugin_email {
|
||||
}
|
||||
$sql .= "where ";
|
||||
$sql .= " u.user_uuid = :user_uuid ";
|
||||
if ($settings['users']['unique'] != "global") {
|
||||
if ($users_unique != "global") {
|
||||
//unique username per domain (not globally unique across system - example: email address)
|
||||
$sql .= "and u.domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
|
||||
@@ -31,7 +31,7 @@ class plugin_ldap {
|
||||
* ldap checks a local or remote ldap database to authenticate the user
|
||||
* @return array [authorized] => true or false
|
||||
*/
|
||||
function ldap() {
|
||||
function ldap(authentication $auth, settings $settings) {
|
||||
|
||||
//show the authentication code view
|
||||
if ($_REQUEST["username"]) {
|
||||
|
||||
@@ -57,17 +57,20 @@ class plugin_totp {
|
||||
* time based one time password aka totp
|
||||
* @return array [authorized] => true or false
|
||||
*/
|
||||
function totp() {
|
||||
function totp(authentication $auth, settings $settings) {
|
||||
|
||||
//pre-process some settings
|
||||
$settings['theme']['favicon'] = !empty($_SESSION['theme']['favicon']['text']) ? $_SESSION['theme']['favicon']['text'] : PROJECT_PATH.'/themes/default/favicon.ico';
|
||||
$settings['login']['destination'] = !empty($_SESSION['login']['destination']['text']) ? $_SESSION['login']['destination']['text'] : '';
|
||||
$settings['users']['unique'] = !empty($_SESSION['users']['unique']['text']) ? $_SESSION['users']['unique']['text'] : '';
|
||||
$settings['theme']['logo'] = !empty($_SESSION['theme']['logo']['text']) ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH.'/themes/default/images/logo_login.png';
|
||||
$settings['theme']['login_logo_width'] = !empty($_SESSION['theme']['login_logo_width']['text']) ? $_SESSION['theme']['login_logo_width']['text'] : 'auto; max-width: 300px';
|
||||
$settings['theme']['login_logo_height'] = !empty($_SESSION['theme']['login_logo_height']['text']) ? $_SESSION['theme']['login_logo_height']['text'] : 'auto; max-height: 300px';
|
||||
$settings['theme']['message_delay'] = isset($_SESSION['theme']['message_delay']) ? 1000 * (float) $_SESSION['theme']['message_delay'] : 3000;
|
||||
$settings['theme']['background_video'] = isset($_SESSION['theme']['background_video'][0]) ? $_SESSION['theme']['background_video'][0] : null;
|
||||
$theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico');
|
||||
$theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png');
|
||||
$theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px');
|
||||
$theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
|
||||
$theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000);
|
||||
$background_videos = $settings->get('theme', 'background_video', null);
|
||||
$theme_background_video = (isset($background_videos) && is_array($background_videos)) ? $background_videos[0] : null;
|
||||
//$login_domain_name_visible = $settings->get('login', 'domain_name_visible');
|
||||
//$login_domain_name = $settings->get('login', 'domain_name');
|
||||
$login_destination = $settings->get('login', 'destination');
|
||||
$users_unique = $settings->get('users', 'unique', '');
|
||||
|
||||
//get the username
|
||||
if (isset($_SESSION["username"])) {
|
||||
@@ -102,16 +105,16 @@ class plugin_totp {
|
||||
|
||||
//assign default values to the template
|
||||
$view->assign("project_path", PROJECT_PATH);
|
||||
$view->assign("login_destination_url", $settings['login']['destination']);
|
||||
$view->assign("favicon", $settings['theme']['favicon']);
|
||||
$view->assign("login_destination_url", $login_destination);
|
||||
$view->assign("favicon", $theme_favicon);
|
||||
$view->assign("login_title", $text['label-username']);
|
||||
$view->assign("login_username", $text['label-username']);
|
||||
$view->assign("login_logo_width", $settings['theme']['login_logo_width']);
|
||||
$view->assign("login_logo_height", $settings['theme']['login_logo_height']);
|
||||
$view->assign("login_logo_source", $settings['theme']['logo']);
|
||||
$view->assign("login_logo_width", $theme_login_logo_width);
|
||||
$view->assign("login_logo_height", $theme_login_logo_height);
|
||||
$view->assign("login_logo_source", $theme_logo);
|
||||
$view->assign("button_login", $text['button-login']);
|
||||
$view->assign("favicon", $settings['theme']['favicon']);
|
||||
$view->assign("message_delay", $settings['theme']['message_delay']);
|
||||
$view->assign("favicon", $theme_favicon);
|
||||
$view->assign("message_delay", $theme_message_delay);
|
||||
|
||||
//messages
|
||||
$view->assign('messages', message::html(true, ' '));
|
||||
@@ -203,16 +206,16 @@ class plugin_totp {
|
||||
|
||||
//assign values to the template
|
||||
$view->assign("project_path", PROJECT_PATH);
|
||||
$view->assign("login_destination_url", $settings['login']['destination']);
|
||||
$view->assign("favicon", $settings['theme']['favicon']);
|
||||
$view->assign("login_destination_url", $login_destination);
|
||||
$view->assign("favicon", $theme_favicon);
|
||||
$view->assign("login_title", $text['label-verify']);
|
||||
$view->assign("login_totp_description", $text['label-totp_description']);
|
||||
$view->assign("login_authentication_code", $text['label-authentication_code']);
|
||||
$view->assign("login_logo_width", $settings['theme']['login_logo_width']);
|
||||
$view->assign("login_logo_height", $settings['theme']['login_logo_height']);
|
||||
$view->assign("login_logo_source", $settings['theme']['logo']);
|
||||
$view->assign("favicon", $settings['theme']['favicon']);
|
||||
$view->assign("background_video", $settings['theme']['background_video']);
|
||||
$view->assign("login_logo_width", $theme_login_logo_width);
|
||||
$view->assign("login_logo_height", $theme_login_logo_height);
|
||||
$view->assign("login_logo_source", $theme_logo);
|
||||
$view->assign("favicon", $theme_favicon);
|
||||
$view->assign("background_video", $theme_background_video);
|
||||
if (!empty($_SESSION['username'])) {
|
||||
$view->assign("username", $_SESSION['username']);
|
||||
$view->assign("button_cancel", $text['button-cancel']);
|
||||
@@ -271,8 +274,8 @@ class plugin_totp {
|
||||
$view->assign("totp_image", base64_encode($image));
|
||||
$view->assign("totp_description", $text['description-totp']);
|
||||
$view->assign("button_next", $text['button-next']);
|
||||
$view->assign("favicon", $settings['theme']['favicon']);
|
||||
$view->assign("message_delay", $settings['theme']['message_delay']);
|
||||
$view->assign("favicon", $theme_favicon);
|
||||
$view->assign("message_delay", $theme_message_delay);
|
||||
|
||||
//messages
|
||||
$view->assign('messages', message::html(true, ' '));
|
||||
@@ -283,7 +286,7 @@ class plugin_totp {
|
||||
else {
|
||||
//assign values to the template
|
||||
$view->assign("button_verify", $text['label-verify']);
|
||||
$view->assign("message_delay", $settings['theme']['message_delay']);
|
||||
$view->assign("message_delay", $theme_message_delay);
|
||||
|
||||
//messages
|
||||
$view->assign('messages', message::html(true, ' '));
|
||||
@@ -305,7 +308,7 @@ class plugin_totp {
|
||||
$sql .= " username = :username\n";
|
||||
$sql .= " or user_email = :username\n";
|
||||
$sql .= ")\n";
|
||||
if ($settings['users']['unique'] != "global") {
|
||||
if ($users_unique != "global") {
|
||||
//unique username per domain (not globally unique across system - example: email address)
|
||||
$sql .= "and domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
@@ -358,7 +361,7 @@ class plugin_totp {
|
||||
}
|
||||
$sql .= "where ";
|
||||
$sql .= " u.user_uuid = :user_uuid ";
|
||||
if ($settings['users']['unique'] != "global") {
|
||||
if ($users_unique != "global") {
|
||||
//unique username per domain (not globally unique across system - example: email address)
|
||||
$sql .= "and u.domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
|
||||
Reference in New Issue
Block a user