Skip to content

Commit 7c81eac

Browse files
committed
improve the verify process; automatic activate
1 parent f55c89d commit 7c81eac

File tree

6 files changed

+48
-47
lines changed

6 files changed

+48
-47
lines changed

lib/Controller/API/Contact/Create.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ function __invoke($REQ, $RES, $ARG)
1616
{
1717
$Contact = [];
1818
$Contact['id'] = _ulid();
19-
// $Contact['flag'] = \OpenTHC\Contact::FLAG_EMAIL_GOOD;
20-
// $Contact['stat'] = 100;
19+
$Contact['stat'] = 102;
2120
$Contact['name'] = trim($_POST['name'] ?: $_POST['email']);
22-
$Contact['email'] = $_POST['email']; // @deprecated
21+
$Contact['email'] = $_POST['email'];
22+
$Contact['phone'] = $_POST['phone'];
23+
24+
if ( ! empty($_POST['email_verify'])) {
25+
$Contact['flag'] = \OpenTHC\Contact::FLAG_EMAIL_GOOD;
26+
}
2327

2428
// $dir = new \OpenTHC\Service\OpenTHC('dir');
2529
// $res = $dir->get('/api/contact?email=%s', rawurlencode($_POST['email']));
@@ -197,11 +201,6 @@ function __invoke($REQ, $RES, $ARG)
197201

198202
$ret_data['id'] = $Contact['id'];
199203

200-
// Pass Token in ARGS if TEST
201-
if ('TEST' == getenv('OPENTHC_TEST')) {
202-
$ret_data['t'] = $act['id'];
203-
}
204-
205204
return $RES->withJSON([
206205
'data' => $ret_data,
207206
'meta' => [],

lib/Controller/Account/Commit.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ function __invoke($REQ, $RES, $ARG)
2323
}
2424

2525
// private function accountCreate($RES, $act_data)
26-
$sso = new \OpenTHC\Service\OpenTHC('sso');
27-
$res = $sso->post('/api/contact', [ 'form_params' => [
26+
$arg = [
2827
'name' => $act_data['account']['contact-name'],
29-
'email' => $act_data['account']['contact-email']
30-
]]);
28+
'email' => $act_data['account']['contact-email'],
29+
'phone' => $act_data['account']['contact-phone']
30+
];
31+
switch ($act_data['intent']) {
32+
case 'account-create':
33+
$arg['email_verify'] = '1';
34+
break;
35+
}
36+
37+
$sso = new \OpenTHC\Service\OpenTHC('sso');
38+
$res = $sso->post('/api/contact', [ 'form_params' => $arg ]);
3139

3240
$ret_args = [];
3341

lib/Controller/Account/Create.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,21 @@ private function _create($RES)
122122
'account' => $_POST,
123123
'ip' => $_SERVER['REMOTE_ADDR'],
124124
];
125+
125126
// Auth Hash Link - Redis
126-
// $tok = Auth_Context_Ticket::set($act_data);
127+
$tok = Auth_Context_Ticket::set($act_data, 900);
128+
127129
// Auth Hash Link - PostgreSQL
128-
$dbc_auth = $this->_container->DBC_AUTH;
129-
$act = new \OpenTHC\Auth_Context_Ticket($dbc_auth);
130-
$act->create($act_data);
131-
$RES = $RES->withAttribute('Auth_Context_Ticket', $act['id']);
130+
// $dbc_auth = $this->_container->DBC_AUTH;
131+
// $act = new \OpenTHC\Auth_Context_Ticket($dbc_auth);
132+
// $act->create($act_data);
133+
// $RES = $RES->withAttribute('Auth_Context_Ticket', $act['id']);
132134

133135
$ret_args['e'] = 'CAC-111';
134136

135137
// Test Mode
136138
if ('TEST' == getenv('OPENTHC_TEST')) {
137-
$ret_args['t'] = $act['id'];
139+
$ret_args['t'] = $tok;
138140
}
139141

140142
return $RES->withRedirect('/done?' . http_build_query($ret_args));

lib/Controller/Verify/Company.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ function post($REQ, $RES, $ARG)
5050

5151
$CY0 = [
5252
'id' => _ulid(),
53-
'name' => $_POST['company-name'] ?: $act['contact']['email'],
53+
'name' => trim($_POST['company-name'] ?: $act['contact']['email']),
5454
'iso3166' => $act['contact']['iso3166'],
5555
'tz'=> $act['contact']['tz'],
56-
// 'cre_meta' => json_encode($_POST),
5756
];
5857

5958
$dbc->insert('auth_company', $CY0);

view/account/create.php

+12-21
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,21 @@
1414
<h1 class="card-header"><?= $data['Page']['title'] ?></h1>
1515
<div class="card-body">
1616

17-
<!--
18-
<div class="mt-4">
19-
<label>Company Name / License ID</label>
20-
<input autocomplete="off" autofocus class="form-control" id="company-name" name="company-name" placeholder="- Company, Inc. -" required>
21-
<div>Should be your registered company name or your government issued business license ID</div>
22-
</div>
23-
-->
17+
<div>
18+
<label>Full Name</label>
19+
<input autocomplete="off" autofocus class="form-control" id="contact-name" name="contact-name" placeholder="- Your Full Name -" required>
20+
</div>
2421

25-
<div class="mt-4">
26-
<label>Contact Name</label>
27-
<input autocomplete="off" autofocus class="form-control" id="contact-name" name="contact-name" placeholder="- Your Full Name -" required>
28-
</div>
22+
<div class="mt-4">
23+
<label>Email</label>
24+
<input autocomplete="off" class="form-control" id="contact-email" inputmode="email" name="contact-email" placeholder="eg: [email protected]" required type="email" value="<?= __h($_SESSION['auth-open-email']) ?>">
25+
</div>
2926

30-
<div class="mt-4">
31-
<label>Email</label>
32-
<input autocomplete="off" class="form-control" id="contact-email" inputmode="email" name="contact-email" placeholder="eg: [email protected]" required type="email" value="<?= h($_SESSION['auth-open-email']) ?>">
33-
</div>
27+
<div class="mt-4">
28+
<label>Phone</label>
29+
<input autocomplete="off" class="form-control" id="contact-phone" inputmode="tel" name="contact-phone" placeholder="eg: +1 202 555 1212" required type="phone">
30+
</div>
3431

35-
<!--
36-
<div class="mt-4">
37-
<label>Phone</label>
38-
<input autocomplete="off" class="form-control" id="contact-phone" inputmode="tel" name="contact-phone" placeholder="eg: +1 202 555 1212" required type="phone">
39-
</div>
40-
-->
4132
</div>
4233

4334
<div class="card-footer">

view/done.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
case 'CAC-111':
1818
$data['Page']['title'] = 'Account Confirmation';
1919
$data['info'] = 'Please check your email to confirm your account.';
20-
$data['body'] = '<p>We have just sent you an email, with the next steps.<p><p>You will need to confirm your request through a link in that message and then complete the verification process.</p>';
21-
// <p>Maybe you want to read more about regulations?</p>
22-
// <a class="btn btn-outline-success" href="https://openthc.com/intro">Introduction to Track and Trace <i class="icon icon-arrow-right"></i></a>
20+
$data['body'] = <<<HTML
21+
<p>We have just sent you an email, with the next steps.<p>
22+
<p>You will need to confirm your request through a link in that message and then complete the verification process.</p>
23+
<p>The message will expire in 15 minutes.</p>
24+
HTML;
2325
break;
2426
case 'CAO-100':
2527
$data['Page']['title'] = 'Check Your Inbox';
@@ -34,12 +36,12 @@
3436
case 'CVM-119':
3537
$data['Page']['title'] = 'Verification Complete';
3638
$data['body'] = <<<HTML
37-
<p>Your Account has been Verified and Activated.</p>
39+
<h2 class="alert alert-success">Your Account has been Verified and Activated.</h2>
3840
<p>You may now sign in.</p>
3941
HTML;
4042
$data['foot'] = <<<HTML
4143
<div class="d-flex justify-content-between">
42-
<a class="btn btn-primary" href="https://openthc.com/sign-in">Sign In <i class="fa-solid fa-arrow-up-right-from-square"></i></a>
44+
<a class="btn btn-primary" href="/auth/open?service={$data['service']}">Sign In <i class="fa-solid fa-arrow-up-right-from-square"></i></a>
4345
</div>
4446
HTML;
4547
break;
@@ -51,7 +53,7 @@
5153
HTML;
5254
$data['foot'] = <<<HTML
5355
<div class="d-flex justify-content-between">
54-
<a class="btn btn-primary" href="https://openthc.com/demo" tabindex="1">Browse Demo <i class="fa-solid fa-arrow-up-right-from-square"></i></a>
56+
<a class="btn btn-primary" href="/profile" tabindex="1">View Profile</a>
5557
<a class="btn btn-outline-danger" href="https://openthc.com/help" tabindex="2" target="_blank">Get Help <i class="fas fa-life-ring"></i></a>
5658
</div>
5759
HTML;

0 commit comments

Comments
 (0)