PluginProbe ʕ •ᴥ•ʔ
Firebase Authentication / 1.7.0
Firebase Authentication v1.7.0
1.7.0 trunk 1.0.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.8 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9
firebase-authentication / admin / class-mo-firebase-customer.php
firebase-authentication / admin Last commit date
css 1 day ago fonts 1 day ago images 1 day ago js 1 day ago partials 1 day ago class-mo-firebase-authentication-admin.php 1 day ago class-mo-firebase-customer.php 1 day ago
class-mo-firebase-customer.php
207 lines
1 <?php
2 /**
3 * Firebase Authentication Customer account
4 *
5 * @package firebase-authentication
6 */
7
8 /**
9 * This class contains the implementation of the miniOrange API requests
10 */
11 class MO_Firebase_Customer {
12
13 /**
14 * Email id
15 *
16 * @var string
17 */
18 public $email;
19 /**
20 * Phone no
21 *
22 * @var string
23 */
24 public $phone;
25
26 /**
27 * Create_customer in miniOrange
28 *
29 * @return string
30 */
31 public function create_customer() {
32 $url = get_option( 'mo_fb_host_name' ) . '/moas/rest/customer/add';
33 $this->email = get_option( 'mo_firebase_authentication_admin_email' );
34 $this->phone = get_option( 'mo_firebase_authentication_admin_phone' );
35 $password = get_option( 'password' );
36 $first_name = get_option( 'mo_firebase_authentication_admin_fname' );
37 $last_name = get_option( 'mo_firebase_authentication_admin_lname' );
38 $company = get_option( 'mo_firebase_authentication_admin_company' );
39
40 $fields = array(
41 'companyName' => $company,
42 'areaOfInterest' => 'WP Firebase Authentication',
43 'firstname' => $first_name,
44 'lastname' => $last_name,
45 'email' => $this->email,
46 'phone' => $this->phone,
47 'password' => $password,
48 );
49 $field_string = wp_json_encode( $fields );
50 $headers = array(
51 'Content-Type' => 'application/json',
52 'charset' => 'UTF - 8',
53 'Authorization' => 'Basic',
54 );
55 $args = array(
56 'method' => 'POST',
57 'body' => $field_string,
58 'timeout' => '5',
59 'redirection' => '5',
60 'httpversion' => '1.0',
61 'blocking' => true,
62 'headers' => $headers,
63
64 );
65
66 $response = wp_remote_post( $url, $args );
67 if ( is_wp_error( $response ) ) {
68 $error_message = $response->get_error_message();
69 echo 'Something went wrong: ' . esc_attr( $error_message );
70 exit();
71 }
72
73 return wp_remote_retrieve_body( $response );
74 }
75
76 /**
77 * Check if customer exists
78 *
79 * @return string
80 */
81 public function check_customer() {
82 $url = get_option( 'mo_fb_host_name' ) . '/moas/rest/customer/check-if-exists';
83 $email = get_option( 'mo_firebase_authentication_admin_email' );
84
85 $fields = array(
86 'email' => $email,
87 );
88 $field_string = wp_json_encode( $fields );
89 $headers = array(
90 'Content-Type' => 'application/json',
91 'charset' => 'UTF - 8',
92 'Authorization' => 'Basic',
93 );
94 $args = array(
95 'method' => 'POST',
96 'body' => $field_string,
97 'timeout' => '5',
98 'redirection' => '5',
99 'httpversion' => '1.0',
100 'blocking' => true,
101 'headers' => $headers,
102 );
103
104 $response = wp_remote_post( $url, $args );
105 if ( is_wp_error( $response ) ) {
106 $error_message = $response->get_error_message();
107 echo 'Something went wrong: ' . esc_attr( $error_message );
108 exit();
109 }
110
111 return wp_remote_retrieve_body( $response );
112 }
113
114 /**
115 * Get miniOrange customer_key
116 *
117 * @return string
118 */
119 public function mo_firebase_auth_get_customer_key() {
120 $url = get_option( 'mo_fb_host_name' ) . '/moas/rest/customer/key';
121 $email = get_option( 'mo_firebase_authentication_admin_email' );
122
123 $password = get_option( 'password' );
124
125 $fields = array(
126 'email' => $email,
127 'password' => $password,
128 );
129 $field_string = wp_json_encode( $fields );
130
131 $headers = array(
132 'Content-Type' => 'application/json',
133 'charset' => 'UTF - 8',
134 'Authorization' => 'Basic',
135 );
136 $args = array(
137 'method' => 'POST',
138 'body' => $field_string,
139 'timeout' => '5',
140 'redirection' => '5',
141 'httpversion' => '1.0',
142 'blocking' => true,
143 'headers' => $headers,
144
145 );
146
147 $response = wp_remote_post( $url, $args );
148 if ( is_wp_error( $response ) ) {
149 $error_message = $response->get_error_message();
150 echo 'Something went wrong: ' . esc_attr( $error_message );
151 exit();
152 }
153
154 return wp_remote_retrieve_body( $response );
155 }
156
157 /**
158 * Customer update call
159 *
160 * @return string
161 */
162 public function mo_firebase_authentication_submit_support_request() {
163
164 $url = get_option( 'mo_fb_host_name' ) . '/moas/api/backupcode/updatestatus';
165 $customer_key = get_option( 'mo_firebase_authentication_admin_customer_key' );
166 $api_key = get_option( 'mo_firebase_authentication_admin_api_key' );
167 $current_time_in_millis = round( microtime( true ) * 1000 );
168 $current_time_in_millis = number_format( $current_time_in_millis, 0, '', '' );
169 $string_to_hash = $customer_key . $current_time_in_millis . $api_key;
170 $hash_value = hash( 'sha512', $string_to_hash );
171 $code = mo_firebase_authentication_decrypt( get_option( 'mo_firebase_authentication_lk' ) );
172 $fields = array(
173 'code' => $code,
174 'customerKey' => $customer_key,
175 'additionalFields' => array( 'field1' => home_url() ),
176 );
177 $field_string = wp_json_encode( $fields );
178
179 $headers = array(
180 'Content-Type' => 'application/json',
181 'Customer-Key' => $customer_key,
182 'Timestamp' => $current_time_in_millis,
183 'Authorization' => $hash_value,
184 );
185 $args = array(
186 'method' => 'POST',
187 'body' => $field_string,
188 'timeout' => '5',
189 'redirection' => '5',
190 'httpversion' => '1.0',
191 'blocking' => true,
192 'headers' => $headers,
193
194 );
195
196 $response = wp_remote_post( $url, $args );
197 if ( is_wp_error( $response ) ) {
198 $error_message = $response->get_error_message();
199 echo 'Something went wrong: ' . esc_attr( $error_message );
200 exit();
201 }
202
203 return wp_remote_retrieve_body( $response );
204 }
205
206 }
207