aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Regate.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Regate.php')
-rw-r--r--Zotlabs/Module/Regate.php85
1 files changed, 54 insertions, 31 deletions
diff --git a/Zotlabs/Module/Regate.php b/Zotlabs/Module/Regate.php
index 372b65433..155f818ef 100644
--- a/Zotlabs/Module/Regate.php
+++ b/Zotlabs/Module/Regate.php
@@ -151,46 +151,62 @@ class Regate extends \Zotlabs\Web\Controller {
zar_log('ZAR1238I ' . $msg . ' ' . $cra['account']['account_email']
. ' ' . $cra['account']['account_language']);
+ authenticate_success($cra['account'],null,true,false,true);
+
$nextpage = 'new_channel';
- $auto_create = get_config('system','auto_channel_create',1);
+ $auto_create = get_config('system', 'auto_channel_create', 1);
if($auto_create) {
- // prepare channel creation
- if($reonar['chan.name'])
- set_aconfig($cra['account']['account_id'], 'register', 'channel_name', $reonar['chan.name']);
- if($reonar['chan.did1'])
- set_aconfig($cra['account']['account_id'], 'register', 'channel_address', $reonar['chan.did1']);
+ $new_channel = ['success' => false];
- $permissions_role = get_config('system','default_permissions_role');
- if($permissions_role)
- set_aconfig($cra['account']['account_id'], 'register', 'permissions_role', $permissions_role);
- }
+ // We do not reserve a channel_address before the registration is verified
+ // and possibly approved by the admin.
+ // If the provided channel_address has been claimed meanwhile,
+ // we will proceed to /new_channel.
- authenticate_success($cra['account'],null,true,false,true);
+ if(isset($reonar['chan.did1']) && check_webbie([$reonar['chan.did1']])) {
- if($auto_create) {
- // create channel
- $new_channel = auto_channel_create($cra['account']['account_id']);
-
- if($new_channel['success']) {
- $channel_id = $new_channel['channel']['channel_id'];
- change_channel($channel_id);
- $nextpage = 'profiles/' . $channel_id;
- $msg = 'ZAR1239I ' . t('Channel successfull created') . ' ' . $did2;
+ // prepare channel creation
+ if($reonar['chan.name'])
+ set_aconfig($cra['account']['account_id'], 'register', 'channel_name', $reonar['chan.name']);
+
+ if($reonar['chan.did1'])
+ set_aconfig($cra['account']['account_id'], 'register', 'channel_address', $reonar['chan.did1']);
+
+ $permissions_role = get_config('system','default_permissions_role');
+ if($permissions_role)
+ set_aconfig($cra['account']['account_id'], 'register', 'permissions_role', $permissions_role);
+
+ // create channel
+ $new_channel = auto_channel_create($cra['account']['account_id']);
+
+ if($new_channel['success']) {
+ $channel_id = $new_channel['channel']['channel_id'];
+ change_channel($channel_id);
+ $nextpage = 'profiles/' . $channel_id;
+ $msg_code = 'ZAR1239I';
+ $msg = t('Channel successfull created') . ' ' . $did2;
+ }
}
- else {
- $msg = 'ZAR1239E ' . t('Channel still not created') . ' ' . $did2;
+
+ if(!$new_channel['success']) {
+ $msg_code = 'ZAR1239E';
+ $msg = t('Automatic channel creation failed. Please create a channel.') . ' ' . $did2;
+ $nextpage = 'new_channel?name=' . $reonar['chan.name'];
}
- zar_log($msg . ' ' . $reonar['chan.did1'] . ' (' . $reonar['chan.name'] . ')');
+
+ zar_log($msg_code . ' ' . $msg . ' ' . $reonar['chan.did1'] . ' (' . $reonar['chan.name'] . ')');
+
}
unset($_SESSION['login_return_url']);
}
else {
q("ROLLBACK");
- $msg = 'ZAR1238E ' . t('Account creation error');
- zar_log($msg . ':' . print_r($cra, true));
+ $msg_code = 'ZAR1238E';
+ $msg = t('Account creation error');
+ zar_log($msg_code . ' ' . $msg . ': ' . print_r($cra, true));
}
}
else {
@@ -200,25 +216,32 @@ class Regate extends \Zotlabs\Web\Controller {
}
else {
// nothing to confirm
- $msg = 'ZAR1236E' . ' ' . t('Verify failed');
+ $msg_code = 'ZAR1236E';
+ $msg = t('Verify failed');
}
}
else {
- $msg = 'ZAR1235E' . ' ' . t('Token verification failed');
+ $msg_code = 'ZAR1235E';
+ $msg = t('Token verification failed');
}
}
else {
- $msg = 'ZAR1234W' . ' ' . t('Request not inside time frame');
+ $msg_code = 'ZAR1234W';
+ $msg = t('Request not inside time frame');
//info($r[0]['reg_startup'] . EOL . $r[0]['reg_expire'] );
}
}
else {
- $msg = 'ZAR1232E' . ' ' . t('Identity unknown');
- zar_log($msg . ':' . $did2 . $didx);
+ $msg_code = 'ZAR1232E';
+ $msg = t('Identity unknown');
+ zar_log($msg_code . ' ' . $msg . ':' . $did2 . $didx);
}
}
else {
- $msg = 'ZAR1231E' . t('dId2 mistaken');
+ $msg_code = 'ZAR1231E';
+ $msg = t('dId2 mistaken');
+ zar_log($msg_code . ' ' . $msg);
+
}
}