aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-04-09 09:49:36 +0000
committerMario <mario@mariovavti.com>2021-04-09 09:49:36 +0000
commit01b081d809d128e0922fb404921f452c51c2ddb2 (patch)
treedb100aa4c3b257943b95ab192514a8a93cfa6ba9
parenta34d8852b6695086ef3c9f5ff882d0d033f7d4a5 (diff)
downloadvolse-hubzilla-01b081d809d128e0922fb404921f452c51c2ddb2.tar.gz
volse-hubzilla-01b081d809d128e0922fb404921f452c51c2ddb2.tar.bz2
volse-hubzilla-01b081d809d128e0922fb404921f452c51c2ddb2.zip
register: only return verified registrations in get_pending_accounts(), more invite handling fixes
-rw-r--r--Zotlabs/Lib/Enotify.php8
-rw-r--r--Zotlabs/Module/Admin/Accounts.php13
-rw-r--r--Zotlabs/Module/Regate.php16
-rw-r--r--Zotlabs/Module/Register.php13
-rw-r--r--Zotlabs/Module/Sse_bs.php4
-rw-r--r--include/account.php5
-rw-r--r--include/js_strings.php3
-rw-r--r--view/js/mod_register.js7
-rw-r--r--view/tpl/js_strings.tpl3
-rw-r--r--view/tpl/register.tpl19
10 files changed, 45 insertions, 46 deletions
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index be93e655c..490557477 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -976,12 +976,6 @@ class Enotify {
static public function format_register($rr) {
- $policy = intval(get_config('system','register_policy'));
-
- $message = (($rr['reg_vfd']) ? t('verified') : t('not verified'));
- if(!$rr['reg_vfd'] && $rr['reg_expires'] < datetime_convert())
- $message = t('expired');
-
$x = [
'notify_link' => z_root() . '/admin/accounts',
'name' => (($rr['reg_email']) ? $rr['reg_email'] : $rr['reg_did2']),
@@ -989,7 +983,7 @@ class Enotify {
'photo' => z_root() . '/' . get_default_profile_photo(48),
'when' => datetime_convert('UTC', date_default_timezone_get(),$rr['reg_created']),
'hclass' => ('notify-unseen'),
- 'message' => $message
+ 'message' => t('verified')
];
return $x;
diff --git a/Zotlabs/Module/Admin/Accounts.php b/Zotlabs/Module/Admin/Accounts.php
index ac46c43aa..9971fd213 100644
--- a/Zotlabs/Module/Admin/Accounts.php
+++ b/Zotlabs/Module/Admin/Accounts.php
@@ -217,18 +217,13 @@ class Accounts {
$tao .= 'tao.zar.zarar = {';
foreach ($pending as $n => $v) {
- if (array_key_exists($v['reg_atip'], $atipn)) {
+ $pending[$n]['status'] = t('Verified');
+
+ if (array_key_exists($v['reg_atip'], $atipn)) {
$pending[$n]['reg_atip'] = $v['reg_atip'] . ' ◄' . $atipn[ $v['reg_atip'] ] . '×';
}
- $pending[$n]['status'] = t('Not verified');
- if($pending[$n]['reg_vfd'])
- $pending[$n]['status'] = t('Verified');
-
- if(!$pending[$n]['reg_vfd'] && $pending[$n]['reg_expires'] < datetime_convert())
- $pending[$n]['status'] = t('Expired');
-
// timezone adjust date_time for display
$pending[$n]['reg_created'] = datetime_convert('UTC', date_default_timezone_get(), $pending[$n]['reg_created']);
$pending[$n]['reg_startup'] = datetime_convert('UTC', date_default_timezone_get(), $pending[$n]['reg_startup']);
@@ -300,7 +295,7 @@ class Accounts {
'$sel_aprv' => t('Approve selected'),
'$h_pending' => t('Registrations waiting for confirm'),
'$th_pending' => array( t('Request date'), t('Verification status'), t('Timeframe'), 'dId2', t('specified,atip') ),
- '$no_pending' => t('No registrations.'),
+ '$no_pending' => t('No verified registrations.'),
'$approve' => t('Approve'),
'$deny' => t('Deny'),
'$delete' => t('Delete'),
diff --git a/Zotlabs/Module/Regate.php b/Zotlabs/Module/Regate.php
index 0c32ebd25..0bca68a0b 100644
--- a/Zotlabs/Module/Regate.php
+++ b/Zotlabs/Module/Regate.php
@@ -99,16 +99,28 @@ class Regate extends \Zotlabs\Web\Controller {
if ( $acpin && ($r['reg_hash'] == $acpin )) {
$flags = $r['reg_flags'];
- if ( ($flags & ACCOUNT_UNVERIFIED ) == ACCOUNT_UNVERIFIED) {
+ if (($flags & ACCOUNT_UNVERIFIED) == ACCOUNT_UNVERIFIED) {
// verification success
$msg = 'ZAR1237I' . ' ' . t('Verify successfull');
$reonar = json_decode( $r['reg_stuff'], true);
$reonar['valid'] = $now . ',' . $ip . ' ' . $did2 . ' ' . $msg;
+
// clear flag
$flags &= $flags ^ ACCOUNT_UNVERIFIED;
+
+ // are we invited by the admin?
+ $isa = get_account_by_id($r['reg_uid']);
+ $isa = ($isa && ($isa['account_roles'] && ACCOUNT_ROLE_ADMIN));
+
+ // approve contra invite by admin
+ if ($isa && get_config('system','register_policy') == REGISTER_APPROVE) {
+ $flags &= $flags ^ ACCOUNT_PENDING;
+ }
+
// sth todo?
$vital = $flags == 0 ? 0 : 1;
+
// set flag
$flags |= REGISTER_AGREED;
zar_log($msg . ' ' . $did2 . ':flags' . $flags . ',rid' . $r['reg_id']);
@@ -123,8 +135,8 @@ class Regate extends \Zotlabs\Web\Controller {
intval($r['reg_id'])
);
- if ( ($flags & ACCOUNT_PENDING ) == ACCOUNT_PENDING ) {
+ if ( ($flags & ACCOUNT_PENDING ) == ACCOUNT_PENDING ) {
$msg .= "\n".t('Last step will be by an instance admin to agree your account request');
$nextpage = 'regate/' . bin2hex($did2) . $didx;
q("COMMIT");
diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php
index 9d2a8aa96..4eece60b3 100644
--- a/Zotlabs/Module/Register.php
+++ b/Zotlabs/Module/Register.php
@@ -214,7 +214,8 @@ class Register extends Controller {
if ($invonly || $invalso) {
$reg = q("SELECT * from register WHERE reg_vital = 1 AND reg_didx = 'i' AND reg_hash = '%s'",
- dbesc($invite_code));
+ dbesc($invite_code)
+ );
if ($reg && count($reg) == 1) {
$reg = $reg[0];
@@ -222,16 +223,6 @@ class Register extends Controller {
if ($reg['reg_startup'] <= $now && $reg['reg_expires'] >= $now) {
- // is invitor admin
- $isa = get_account_by_id($reg['reg_uid']);
- $isa = ( $isa && ($isa['account_roles'] && ACCOUNT_ROLE_ADMIN) );
-
- // FIXME: set the correct flags if invitee is admin so we do not need to approve anyway if approve is on
- // approve contra invite by admin
- if ($isa && $policy == REGISTER_APPROVE)
- $flags &= $flags ^ ACCOUNT_PENDING;
-
-
if ($auto_create) {
$reonar['chan.name'] = notags(trim($arr['name']));
$reonar['chan.did1'] = notags(trim($arr['nickname']));
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 271d040fd..cc67c8eb7 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -688,6 +688,10 @@ class Sse_bs extends Controller {
if(! self::$uid && ! is_site_admin())
return $result;
+ $policy = intval(get_config('system','register_policy'));
+ if(($policy & REGISTER_APPROVE) != REGISTER_APPROVE)
+ return $result;
+
if(! (self::$vnotify & VNOTIFY_REGISTER))
return $result;
diff --git a/include/account.php b/include/account.php
index 10131c5d4..f7e2c7e32 100644
--- a/include/account.php
+++ b/include/account.php
@@ -1271,9 +1271,8 @@ function get_pending_accounts() {
// better useability at the moment to tell all (ACCOUNT_PENDING >= 0) instead of (> 0 for those need approval)
- $r = q("SELECT reg_did2, reg_created, reg_startup, reg_expires, reg_email, reg_atip, reg_hash, reg_id,
- CASE (reg_flags & %d) WHEN 0 THEN 1 WHEN 1 THEN 0 END AS reg_vfd
- FROM register WHERE reg_vital = 1 AND (reg_flags & %d) >= 0",
+ $r = q("SELECT reg_did2, reg_created, reg_startup, reg_expires, reg_email, reg_atip, reg_hash, reg_id
+ FROM register WHERE reg_vital = 1 AND (reg_flags & %d) = 0 AND (reg_flags & %d) >= 0",
intval(ACCOUNT_UNVERIFIED),
intval(ACCOUNT_PENDING)
);
diff --git a/include/js_strings.php b/include/js_strings.php
index 25b73d71e..ed73b0420 100644
--- a/include/js_strings.php
+++ b/include/js_strings.php
@@ -119,7 +119,8 @@ function js_strings() {
'$download_info' => t('Please stand by while your download is being prepared.'),
// mod register
- '$email_not_valid' => t('Email address not valid')
+ '$email_not_valid' => t('Email address not valid'),
+ '$email_required' => t('Required')
));
}
diff --git a/view/js/mod_register.js b/view/js/mod_register.js
index 7ad972c79..948ba756b 100644
--- a/view/js/mod_register.js
+++ b/view/js/mod_register.js
@@ -10,7 +10,9 @@ $(document).ready(function() {
$(this).html(date.toLocaleString(undefined, {weekday: 'short', hour: 'numeric', minute: 'numeric'}));
});
- $('#zar014').click( function () { $('#zar015').toggle(); });
+ $('#zar014').click( function () {
+ $('#zar015').toggle();
+ });
$('#id_invite_code').blur(function() {
if($('#id_invite_code').val() === '')
@@ -20,8 +22,9 @@ $(document).ready(function() {
var zreg_invite = $('#id_invite_code').val();
$.get('register/invite_check.json?f=&invite_code=' + encodeURIComponent(zreg_invite),function(data) {
if(!data.error) {
- // FIXME: set email field to required -> $('#help_email')
$('#register-form input, #register-form button').removeAttr('disabled');
+ // email is always mandatory if using invite code
+ $('#help_email').removeClass('text-muted').addClass('text-danger').html(aStr['email_required']);
}
$('#invite-spinner').hide();
});
diff --git a/view/tpl/js_strings.tpl b/view/tpl/js_strings.tpl
index c0d8d104e..8f05165f1 100644
--- a/view/tpl/js_strings.tpl
+++ b/view/tpl/js_strings.tpl
@@ -72,7 +72,8 @@
'download_info' : "{{$download_info}}",
// mod register
- 'email_not_valid' : "{{$email_not_valid}}"
+ 'email_not_valid' : "{{$email_not_valid}}",
+ 'email_required' : "{{$email_required}}"
};
diff --git a/view/tpl/register.tpl b/view/tpl/register.tpl
index 7940b8945..fe67abe89 100644
--- a/view/tpl/register.tpl
+++ b/view/tpl/register.tpl
@@ -19,16 +19,6 @@
</div>
{{/if}}
- {{if $auto_create}}
- {{if $default_role}}
- <input type="hidden" name="permissions_role" value="{{$default_role}}" />
- {{else}}
- <div class="section-content-info-wrapper">
- {{$help_role}}
- </div>
- {{include file="field_select_grouped.tpl" field=$role}}
- {{/if}}
-
{{if $invitations}}
<a id="zar014" href="javascript:;" style="display: inline-block;">{{$haveivc}}</a>
<div id="zar015" style="display: none;">
@@ -39,6 +29,15 @@
</div>
{{/if}}
+ {{if $auto_create}}
+ {{if $default_role}}
+ <input type="hidden" name="permissions_role" value="{{$default_role}}" />
+ {{else}}
+ <div class="section-content-info-wrapper">
+ {{$help_role}}
+ </div>
+ {{include file="field_select_grouped.tpl" field=$role}}
+ {{/if}}
<div class="position-relative">
<div id="name-spinner" class="spinner-wrapper position-absolute" style="top: 2.5rem; right: 0.5rem;"><div class="spinner s"></div></div>