PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.10.0
Fluent Support – Helpdesk & Customer Support Ticket System v1.10.0
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / app / Hooks / Handlers / EmailVerificationHandler.php

EmailVerificationHandler.php in Fluent Support – Helpdesk & Customer Support Ticket System 1.10.0, at app/Hooks/Handlers/EmailVerificationHandler.php

90 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Hooks\Handlers;
4
5 use FluentSupport\App\Models\Meta;
6 use FluentSupport\App\Services\Helper;
7 use FluentSupport\Framework\Support\Arr;
8
9
10 class EmailVerificationHandler
11 {
12 public static function sendSignupEmailVerificationHtml($formData)
13 {
14 try {
15 $verifcationCode = str_pad(random_int(100123, 900987), 6, 0, STR_PAD_LEFT);
16 } catch (\Exception $e) {
17 $verifcationCode = str_pad(wp_rand(100123, 900987), 6, 0, STR_PAD_LEFT);
18 }
19
20 $string = $formData['email'] . '-' . wp_generate_uuid4() . wp_rand(1, 99999999);
21 $hash = wp_hash_password($string);
22 $hash = sanitize_title($hash, '', 'display');
23 $hash .= $formData['email'] . '-' . time();
24
25 $data = array(
26 'login_hash' => $hash,
27 'status' => 'issued',
28 'ip_address' => Helper::getIp(),
29 'use_type' => 'signup_verification',
30 'used_count' => 0,
31 'two_fa_code_hash' => wp_hash_password($verifcationCode),
32 'valid_till' => date('Y-m-d H:i:s', current_time('timestamp') + 10 * 60),
33 'created_at' => current_time('mysql'),
34 'updated_at' => current_time('mysql')
35 );
36
37 Meta::insert([
38 'object_type' => 'fs_login_hashes',
39 'key' => $hash,
40 'value' => maybe_serialize($data)
41 ]);
42
43 $mailSubject = apply_filters("fluent_support/signup_verification_mail_subject", sprintf(__('Your registration verification code for %s', 'fluent-support'), get_bloginfo('name')));
44
45 $pStart = '<p style="font-family: Arial, sans-serif; font-size: 16px; font-weight: normal; margin: 0; margin-bottom: 16px;">';
46
47 $message = $pStart . sprintf(__('Hello %s,', 'fluent-support'), Arr::get($formData, 'first_name')) . '</p>' .
48 $pStart . __('Thank you for registering with us! To complete the setup of your account, please enter the verification code below on the registration page.', 'fluent-support') . '</p>' .
49 $pStart . '<b>' . sprintf(__('Verification Code: %s', 'fluent-support'), $verifcationCode) . '</b></p>' .
50 '<br />' .
51 $pStart . __('This code is valid for 10 minutes and is meant to ensure the security of your account. If you did not initiate this request, please ignore this email.', 'fluent-support') . '</p>';
52
53 $message = apply_filters('fluent_support/signup_verification_email_body', $message, $verifcationCode, $formData);
54
55 $data = [
56 'body' => $message,
57 'pre_header' => __('Activate your account', 'fluent-support'),
58 'show_footer' => false
59 ];
60
61 $message = Helper::loadView('notification', $data);
62 $headers = array('Content-Type: text/html; charset=UTF-8');
63
64 \wp_mail($formData['email'], $mailSubject, $message, $headers);
65
66 ob_start();
67 ?>
68 <div class="fs_signup_verification">
69 <div class="fs_field_group fs_field_verification">
70 <p><?php echo esc_html(sprintf(__('A verification code has been sent to %s. Please provide the code below:', 'fluent-support'), $formData['email'])); ?></p>
71 <input type="hidden" name="_email_verification_hash" value="<?php echo esc_attr($hash); ?>"/>
72 <div class="fs_field_label is-required">
73 <label for="fs_field_verification"><?php esc_html_e('Verification Code', 'fluent-support'); ?></label>
74 </div>
75 <div class="fs_input_wrap">
76 <input type="text" id="fs_field_verification" placeholder="" name="_email_verification_token" required>
77 </div>
78 </div>
79 <button
80 style="display: inline-block; cursor: pointer; border: 0; background: #2271b1; color: #fff; text-decoration: none; text-shadow: none; min-height: 32px; padding: 8px 24px; font-size: 14px; border-radius: 3px; margin-top: 10px;"
81 id="fs_verification_submit" type="submit">
82 <?php esc_html_e('Complete Signup', 'fluent-support'); ?>
83 </button>
84 </div>
85 <?php
86 return ob_get_clean();
87 }
88
89 }
90