mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:55:19 +00:00
Issue with configurable site age limit, vagueness when informing about email validation policy; added email validation resend ability and the option to input a verification code at a webpage though both require additional work to provide these abilities.
This commit is contained in:
parent
e3c7200b6f
commit
660079bd2a
3 changed files with 48 additions and 15 deletions
|
@ -217,6 +217,9 @@ class Register extends \Zotlabs\Web\Controller {
|
||||||
$privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "");
|
$privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "");
|
||||||
|
|
||||||
$perm_roles = \Zotlabs\Access\PermissionRoles::roles();
|
$perm_roles = \Zotlabs\Access\PermissionRoles::roles();
|
||||||
|
|
||||||
|
// A new account will not have a techlevel, but accounts can also be created by the administrator.
|
||||||
|
|
||||||
if((get_account_techlevel() < 4) && $privacy_role !== 'custom')
|
if((get_account_techlevel() < 4) && $privacy_role !== 'custom')
|
||||||
unset($perm_roles[t('Other')]);
|
unset($perm_roles[t('Other')]);
|
||||||
|
|
||||||
|
@ -231,15 +234,17 @@ class Register extends \Zotlabs\Web\Controller {
|
||||||
// Configurable whether to restrict age or not - default is based on international legal requirements
|
// Configurable whether to restrict age or not - default is based on international legal requirements
|
||||||
// This can be relaxed if you are on a restricted server that does not share with public servers
|
// This can be relaxed if you are on a restricted server that does not share with public servers
|
||||||
|
|
||||||
if(get_config('system','no_age_restriction'))
|
if(get_config('system','no_age_restriction')) {
|
||||||
$label_tos = sprintf( t('I accept the %s for this website'), $toslink);
|
$label_tos = sprintf( t('I accept the %s for this website'), $toslink);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
$age = get_config('system','minimum_age');
|
$age = get_config('system','minimum_age');
|
||||||
if(!$age) {
|
if(!$age) {
|
||||||
$age = 13;
|
$age = 13;
|
||||||
}
|
}
|
||||||
$label_tos = sprintf( t('I am over %s years of age and accept the %s for this website'), $age, $toslink);
|
$label_tos = sprintf( t('I am over %s years of age and accept the %s for this website'), $age, $toslink);
|
||||||
|
}
|
||||||
|
|
||||||
$enable_tos = 1 - intval(get_config('system','no_termsofservice'));
|
$enable_tos = 1 - intval(get_config('system','no_termsofservice'));
|
||||||
|
|
||||||
$email = array('email', t('Your email address'), ((x($_REQUEST,'email')) ? strip_tags(trim($_REQUEST['email'])) : ""));
|
$email = array('email', t('Your email address'), ((x($_REQUEST,'email')) ? strip_tags(trim($_REQUEST['email'])) : ""));
|
||||||
|
@ -255,6 +260,7 @@ class Register extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
$auto_create = (get_config('system','auto_channel_create') ? true : false);
|
$auto_create = (get_config('system','auto_channel_create') ? true : false);
|
||||||
$default_role = get_config('system','default_permissions_role');
|
$default_role = get_config('system','default_permissions_role');
|
||||||
|
$email_verify = get_config('system','verify_email');
|
||||||
|
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
|
|
||||||
|
@ -278,7 +284,7 @@ class Register extends \Zotlabs\Web\Controller {
|
||||||
'$pass1' => $password,
|
'$pass1' => $password,
|
||||||
'$pass2' => $password2,
|
'$pass2' => $password2,
|
||||||
'$submit' => t('Register'),
|
'$submit' => t('Register'),
|
||||||
'$verify_note' => t('This site may require email verification after submitting this form. If you are returned to a login page, please check your email for instructions.')
|
'$verify_note' => (($email_verify) ? t('This site requires email verification. After completing this form, please check your email for further instructions.') : ''),
|
||||||
));
|
));
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
|
@ -262,24 +262,46 @@ function create_account($arr) {
|
||||||
|
|
||||||
function verify_email_address($arr) {
|
function verify_email_address($arr) {
|
||||||
|
|
||||||
$hash = random_string();
|
if(array_key_exists('resend',$arr)) {
|
||||||
|
$email = $arr['email'];
|
||||||
|
$a = q("select * from account where account_email = '%s' limit 1",
|
||||||
|
dbesc($arr['email'])
|
||||||
|
}
|
||||||
|
if(! ($a && ($a[0]['account_flags'] & ACCOUNT_UNVERIFIED))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$account = $a[0];
|
||||||
|
$v = q("select * from register where uid = %d and password = 'verify' limit 1",
|
||||||
|
intval($account['account_id'])
|
||||||
|
);
|
||||||
|
if($v) {
|
||||||
|
$hash = $v[0]['hash'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$hash = random_string(24);
|
||||||
|
|
||||||
$r = q("INSERT INTO register ( hash, created, uid, password, lang ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
|
$r = q("INSERT INTO register ( hash, created, uid, password, lang ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($arr['account']['account_id']),
|
intval($arr['account']['account_id']),
|
||||||
dbesc('verify'),
|
dbesc('verify'),
|
||||||
dbesc($arr['account']['account_language'])
|
dbesc($arr['account']['account_language'])
|
||||||
);
|
);
|
||||||
|
$account = $arr['account'];
|
||||||
|
}
|
||||||
|
|
||||||
push_lang(($arr['account']['account_language']) ? $arr['account']['account_language'] : 'en');
|
push_lang(($account['account_language']) ? $account['account_language'] : 'en');
|
||||||
|
|
||||||
$email_msg = replace_macros(get_intltext_template('register_verify_member.tpl'),
|
$email_msg = replace_macros(get_intltext_template('register_verify_member.tpl'),
|
||||||
[
|
[
|
||||||
'$sitename' => get_config('system','sitename'),
|
'$sitename' => get_config('system','sitename'),
|
||||||
'$siteurl' => z_root(),
|
'$siteurl' => z_root(),
|
||||||
'$email' => $arr['email'],
|
'$email' => $arr['email'],
|
||||||
'$uid' => $arr['account']['account_id'],
|
'$uid' => $account['account_id'],
|
||||||
'$hash' => $hash,
|
'$hash' => $hash,
|
||||||
'$details' => $details
|
'$details' => $details
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,7 +10,12 @@ Login with the password you chose at registration.
|
||||||
|
|
||||||
We need to verify your email address in order to give you full access.
|
We need to verify your email address in order to give you full access.
|
||||||
|
|
||||||
If you registered this account, please visit the following link:
|
Your validation code is
|
||||||
|
|
||||||
|
{{$hash}}
|
||||||
|
|
||||||
|
|
||||||
|
If you registered this account, please enter the validation code when requested or visit the following link:
|
||||||
|
|
||||||
{{$siteurl}}/regver/allow/{{$hash}}
|
{{$siteurl}}/regver/allow/{{$hash}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue