mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Added activation page to allow activating email accounts directly from flexisip-account-manager + added domain
This commit is contained in:
parent
39b5e6fc16
commit
b856d7b276
5 changed files with 82 additions and 5 deletions
|
|
@ -19,7 +19,7 @@ define("EMAIL_SITE", "https://linphone.org");
|
|||
|
||||
/*
|
||||
* The link to open when click on activation
|
||||
* It can have a %link%, %username% and %algo% parameter
|
||||
* It can have a %link%, %username%, %domain%, and %algo% parameter
|
||||
*
|
||||
* Default value: www.linphone.org
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#%define _datadir %{_datarootdir}
|
||||
#%define _docdir %{_datadir}/doc
|
||||
|
||||
%define build_number 22
|
||||
%define build_number 23
|
||||
%define var_dir /var/opt/belledonne-communications
|
||||
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager
|
||||
%define env_file "$RPM_BUILD_ROOT/etc/flexisip-account-manager/flexiapi.env"
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function send_email($email, $subject, $text, $html)
|
|||
}
|
||||
}
|
||||
|
||||
function send_email_with_activation_link($email, $key, $username, $algo)
|
||||
function send_email_with_activation_link($email, $key, $username, $domain, $algo)
|
||||
{
|
||||
if (!EMAIL_ENABLED) {
|
||||
Logger::getInstance()->warning("[EMAIL] Emails are disabled");
|
||||
|
|
@ -81,6 +81,7 @@ function send_email_with_activation_link($email, $key, $username, $algo)
|
|||
$link = $pageURL . EMAIL_ACTIVATION_LINK;
|
||||
$link = str_replace("%key%", $key, $link);
|
||||
$link = str_replace("%username%", $username, $link);
|
||||
$link = str_replace("%domain%", $domain, $link);
|
||||
$link = str_replace("%algo%", $algo, $link);
|
||||
Logger::getInstance()->debug("[EMAIL] Activation link is " . $link);
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ function xmlrpc_create_email_account($method, $args)
|
|||
}
|
||||
|
||||
if (SEND_ACTIVATION_EMAIL && EMAIL_ENABLED) {
|
||||
send_email_with_activation_link($email, $account->confirmation_key, $account->username, $algo);
|
||||
send_email_with_activation_link($email, $account->confirmation_key, $account->username, $account->domain, $algo);
|
||||
} elseif (AUTO_ACTIVATE_ACCOUNT) {
|
||||
//TODO
|
||||
/*if (USE_IN_APP_PURCHASES) {
|
||||
|
|
@ -177,7 +177,7 @@ function xmlrpc_create_email_md5_sha256_account($method, $args)
|
|||
}
|
||||
|
||||
if (SEND_ACTIVATION_EMAIL && EMAIL_ENABLED) {
|
||||
send_email_with_activation_link($email, $account->confirmation_key, $account->username, SHA256);
|
||||
send_email_with_activation_link($email, $account->confirmation_key, $account->username, $account->domain, SHA256);
|
||||
} elseif (AUTO_ACTIVATE_ACCOUNT) {
|
||||
//TODO
|
||||
/*if (USE_IN_APP_PURCHASES) {
|
||||
|
|
|
|||
76
src/xmlrpc/activation.php
Normal file
76
src/xmlrpc/activation.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Flexisip Account Manager is a set of tools to manage SIP accounts.
|
||||
Copyright (C) 2019 Belledonne Communications SARL, All rights reserved.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
include_once __DIR__ . '/../database/database.php';
|
||||
|
||||
include_once __DIR__ . '/../objects/account.php';
|
||||
include_once __DIR__ . '/../objects/password.php';
|
||||
include_once __DIR__ . '/../objects/alias.php';
|
||||
include_once __DIR__ . '/../objects/user_info.php';
|
||||
|
||||
include_once __DIR__ . '/../misc/utilities.php';
|
||||
|
||||
include_once __DIR__ . '/accounts_email.php';
|
||||
include_once __DIR__ . '/accounts_phone.php';
|
||||
|
||||
include_once __DIR__ . '/../misc/results_values.php';
|
||||
|
||||
function activate_email_account($user, $domain, $key, $algo) {
|
||||
$domain = get_domain($domain);
|
||||
$algo = get_algo($algo);
|
||||
Logger::getInstance()->message("[HTTP] activate_email_account(" . $user . ", " . $domain . ", " . $key . ", " . $algo . ")");
|
||||
|
||||
if (!check_parameter($user)) {
|
||||
return MISSING_USERNAME_PARAM;
|
||||
} elseif ($algo == null) {
|
||||
return ALGO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
$account = new Account($db);
|
||||
$account->username = $user;
|
||||
$account->domain = $domain;
|
||||
|
||||
if (!$account->getOne()) {
|
||||
Logger::getInstance()->error("[HTTP] Account not found");
|
||||
return ACCOUNT_NOT_FOUND;
|
||||
} elseif ($account->activated != "0") {
|
||||
Logger::getInstance()->warning("[HTTP] Account already activated");
|
||||
return ACCOUNT_ALREADY_ACTIVATED;
|
||||
}
|
||||
|
||||
if (!is_key_matching($key, $account)) {
|
||||
Logger::getInstance()->error("[HTTP] Key doesn't match");
|
||||
return KEY_DOESNT_MATCH;
|
||||
}
|
||||
|
||||
$account->activated = "1";
|
||||
$account->update();
|
||||
Logger::getInstance()->message("[HTTP] Account activated");
|
||||
}
|
||||
|
||||
$user = $_GET["username"];
|
||||
$domain = $_GET["domain"];
|
||||
$key = $_GET["confirmation_key"];
|
||||
$algo = $_GET["algo"];
|
||||
activate_email_account($user, $domain, $key, $algo);
|
||||
|
||||
?>
|
||||
Loading…
Add table
Reference in a new issue