PluginProbe ʕ •ᴥ•ʔ
Firebase Authentication / 1.5.7
Firebase Authentication v1.5.7
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 / firebase-authentication.php
firebase-authentication Last commit date
admin 4 years ago includes 4 years ago languages 4 years ago public 4 years ago views 4 years ago README.txt 4 years ago class-contact-us.php 4 years ago class-mo-firebase-config.php 4 years ago firebase-authentication.php 4 years ago index.php 4 years ago uninstall.php 4 years ago
firebase-authentication.php
524 lines
1 <?php
2 /**
3 *
4 * @link https://miniorange.com
5 * @since 1.0.0
6 * @package Firebase_Authentication
7 *
8 * @wordpress-plugin
9 * Plugin Name: Firebase Authentication
10 * Plugin URI: firebase-authentication
11 * Description: This plugin allows login into Wordpress using Firebase as Identity provider.
12 * Version: 1.5.7
13 * Author: miniOrange
14 * Author URI: https://miniorange.com
15 * License: MIT/Expat
16 */
17
18
19 // If this file is called directly, abort.
20 if ( ! defined( 'WPINC' ) ) {
21 die;
22 }
23
24 /**
25 * Currently plugin version.
26 * Start at version 1.0.0 and use SemVer - https://semver.org
27 * Rename this for your plugin and update it as you release new versions.
28 */
29 define( 'MO_FIREBASE_AUTHENTICATION_VERSION', '1.5.7' );
30
31 /**
32 * The code that runs during plugin activation.
33 * This action is documented in includes/class-firebase-authentication-activator.php
34 */
35 function mo_firebase_activate_firebase_authentication() {
36 require_once plugin_dir_path( __FILE__ ) . 'includes/class-firebase-authentication-activator.php';
37 MO_Firebase_Authentication_Activator::activate();
38 }
39
40 /**
41 * The code that runs during plugin deactivation.
42 * This action is documented in includes/class-firebase-authentication-deactivator.php
43 */
44 function mo_firebase_deactivate_firebase_authentication() {
45 require_once plugin_dir_path( __FILE__ ) . 'includes/class-firebase-authentication-deactivator.php';
46 MO_Firebase_Authentication_Deactivator::deactivate();
47 }
48
49 register_activation_hook( __FILE__, 'mo_firebase_activate_firebase_authentication' );
50 register_deactivation_hook( __FILE__, 'mo_firebase_deactivate_firebase_authentication' );
51
52 /**
53 * The core plugin class that is used to define internationalization,
54 * admin-specific hooks, and public-facing site hooks.
55 */
56 require plugin_dir_path( __FILE__ ) . 'includes/class-firebase-authentication.php';
57 require_once 'class-mo-firebase-config.php';
58 require('views/feedback_form.php');
59 require('class-contact-us.php');
60 require('admin/class-firebase-authentication-customer.php');
61
62
63 /**
64 * Begins execution of the plugin.
65 *
66 * Since everything within the plugin is registered via hooks,
67 * then kicking off the plugin from this point in the file does
68 * not affect the page life cycle.
69 *
70 * @since 1.0.0
71 */
72 function mo_firebase_run_firebase_authentication() {
73
74 $plugin = new MO_Firebase_Authentication();
75 $plugin->run();
76
77 }
78 mo_firebase_run_firebase_authentication();
79
80 function mo_firebase_authentication_is_customer_registered() {
81 $email = get_option('mo_firebase_authentication_admin_email');
82 // $phone = get_option('mo_firebase_authentication_admin_phone');
83 $customerKey = get_option('mo_firebase_authentication_admin_customer_key');
84 // if( ! $email || ! $phone || ! $customerKey || ! is_numeric( trim( $customerKey ) ) ) {
85 if( ! $email || ! $customerKey || ! is_numeric( trim( $customerKey ) ) ) {
86
87 return 0;
88 } else {
89 return 1;
90 }
91 }
92 function mo_firebase_authentication_is_clv() {
93 $licenseKey = get_option('mo_firebase_authentication_lk');
94 $isverified = get_option('mo_firebase_authentication_lv');
95 if($isverified)
96 $isverified = mo_firebase_authentication_decrypt($isverified);
97
98 if(!empty($licenseKey) && $isverified=="true") {
99 return 1;
100 }
101 return 0;
102 }
103
104 function mo_firebase_authentication_encrypt($str){
105 $pass = get_option("mo_firebase_authentication_customer_token");
106 $pass = str_split(str_pad('', strlen($str), $pass, STR_PAD_RIGHT));
107 $stra = str_split($str);
108 foreach($stra as $k=>$v){
109 $tmp = ord($v)+ord($pass[$k]);
110 $stra[$k] = chr( $tmp > 255 ?($tmp-256):$tmp);
111 }
112 return base64_encode(join('', $stra));
113 }
114
115 function mo_firebase_authentication_decrypt($str){
116 $str = base64_decode($str);
117 $pass = get_option("mo_firebase_authentication_customer_token");
118 $pass = str_split(str_pad('', strlen($str), $pass, STR_PAD_RIGHT));
119 $stra = str_split($str);
120 foreach($stra as $k=>$v){
121 $tmp = ord($v)-ord($pass[$k]);
122 $stra[$k] = chr( $tmp < 0 ?($tmp+256):$tmp);
123 }
124 return join('', $stra);
125 }
126
127
128 class mo_firebase_authentication_login {
129 function __construct() {
130 add_action( 'init', array( $this, 'postResgiter' ) );
131 add_action( 'admin_init', array( $this, 'mo_firebase_auth_deactivate' ) );
132 if ( get_option( 'mo_enable_firebase_auth' ) == 1 ) {
133 if ( strpos( $_SERVER['REQUEST_URI'], '/wp-json' ) === false ) {
134 remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 );
135 remove_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 );
136 add_filter( 'authenticate', array( $this, 'mo_firebase_auth' ), 0, 3 );
137 }
138 }
139 remove_action( 'admin_notices', array( $this, 'mo_firebase_auth_success_message') );
140 remove_action( 'admin_notices', array( $this, 'mo_firebase_auth_error_message') );
141 add_action( 'admin_footer', array( $this, 'mo_firebase_auth_feedback_request' ) );
142 update_option( 'host_name', 'https://login.xecurify.com' );
143 }
144
145 function postResgiter() {
146 if ( isset( $_POST['verify_user'] ) && isset( $_REQUEST['page'] ) && sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) == 'mo_firebase_authentication' && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['mo_firebase_auth_config_field'] ) ), 'mo_firebase_auth_config_form' ) ) {
147
148 if( current_user_can( 'administrator' ) ) {
149 update_option( 'mo_firebase_auth_disable_wordpress_login', isset( $_POST['disable_wordpress_login'] ) ? (int)filter_var( $_POST['disable_wordpress_login'], FILTER_SANITIZE_NUMBER_INT ) : 0 );
150
151 update_option('mo_firebase_auth_enable_admin_wp_login', isset($_POST['mo_firebase_auth_enable_admin_wp_login']) ? $_POST['mo_firebase_auth_enable_admin_wp_login'] : 0);
152
153 $project_id = isset( $_POST['projectid'] ) ? sanitize_text_field( $_POST['projectid'] ) : '';
154 update_option( 'mo_firebase_auth_project_id', $project_id );
155
156 $api_key = isset( $_POST['apikey'] ) ? sanitize_text_field( $_POST['apikey'] ) : '';
157 update_option( 'mo_firebase_auth_api_key', $api_key );
158
159 $this->mo_firebase_auth_store_certificates();
160 update_option( 'mo_firebase_auth_message', 'Configurations saved successfully. Please <a href="' . admin_url( 'admin.php?page=mo_firebase_authentication&tab=config#test_authentication' ) .'">Test Authentication</a> before trying to Login.');
161 $this->mo_firebase_auth_show_success_message();
162 }
163 }
164 }
165
166 function mo_firebase_auth_store_certificates(){
167 $response = wp_remote_get( 'https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com' );
168 if ( is_array( $response ) ) {
169 $header = $response['headers']; // array of http header lines
170 $body = $response['body']; // use the content
171
172 $split_result = explode( ":", $body );
173 $count = count( $split_result );
174 $kid1 = substr( $split_result[0], 5, 40 );
175 $s = explode( ",", $split_result[1] );
176 $c1 = substr( $s[0], 2, 1158 );
177 $c1 = str_replace( '\n', '', $c1 );
178 update_option( 'mo_firebase_auth_kid1', $kid1 );
179 update_option( 'mo_firebase_auth_cert1', $c1 );
180 if( $count == 3 ) {
181 $kid2 = substr( $s[1], 4, 40 );
182 $c2 = explode( "}", $split_result[2] );
183 $c2[0] = substr( $c2[0], 2, 1158 );
184 $c2[0] = str_replace( '\n', '', $c2[0] );
185 update_option( 'mo_firebase_auth_kid2', $kid2 );
186 update_option( 'mo_firebase_auth_cert2', $c2[0] );
187 } elseif ( $count > 3) {
188 $kid2 = substr( $s[1], 4, 40 );
189 $s2 = explode( ",", $split_result[2] );
190 $c2 = substr( $s2[0], 2, 1158 );
191 $kid3 = substr( $s2[1], 4, 40 );
192 $c3 = explode( "}", $split_result[3] );
193 $c3[0] = substr( $c3[0], 2, 1158 );
194 $c2 = str_replace( '\n', '', $c2 );
195 update_option( 'mo_firebase_auth_kid2', $kid2 );
196 update_option( 'mo_firebase_auth_cert2', $c2 );
197 $c3[0] = str_replace( '\n', '', $c3[0] );
198 update_option( 'mo_firebase_auth_kid3', $kid3 );
199 update_option( 'mo_firebase_auth_cert3', $c3[0] );
200 }
201 } else {
202 if ( is_wp_error( $response ) ) {
203 $error_message = $response->get_error_message();
204 echo "Something went wrong: ".esc_attr($error_message);
205 exit();
206 }
207 }
208 }
209
210 function mo_fb_clear_wp_login_errors($errors, $redirect_to){
211 return new WP_Error();
212 }
213
214
215 function mo_firebase_auth( $default_user, $username, $password ) {
216
217 if( "POST" !== sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ) {
218 add_filter( 'wp_login_errors', array( $this, 'mo_fb_clear_wp_login_errors' ), 0, 2 );
219 return $default_user;
220 }
221
222 if ( empty( $username ) || empty ( $password ) ) {
223
224 $error = new WP_Error();
225 //create new error object and add errors to it.
226
227 if ( empty( $username ) ) { //No email
228 $error->add( 'empty_username', __( '<strong>ERROR</strong>: Email field is empty.' ) );
229 }
230
231 else if ( empty( $password ) ) { //No password
232 $error->add( 'empty_password', __( '<strong>ERROR</strong>: Password field is empty.' ) );
233 }
234 return $error;
235 }
236
237 $mo_firebase_config_obj = new Mo_Firebase_Config();
238 $fb_user = $mo_firebase_config_obj->mo_firebase_authenticate_call($username, $password);
239 $fb_user = json_decode($fb_user, true);
240
241 if(isset($fb_user['idToken'])){
242 $response = $mo_firebase_config_obj->mo_fb_login_user($fb_user['idToken']);
243 }
244 else{
245
246 $error_message = $fb_user['error']['message'];
247 if($error_message == 'INVALID_EMAIL' || $error_message == 'EMAIL_NOT_FOUND'){
248 if ( get_option( 'mo_firebase_auth_disable_wordpress_login' ) == false ) {
249 $user = get_user_by( "login", $username );
250 if ( !$user ) {
251 $user = get_user_by( "email", $username );
252 }
253 if ( $user && wp_check_password( $password, $user->data->user_pass, $user->ID ) ) {
254 return $user;
255 }
256 }
257 else if ( get_option( 'mo_firebase_auth_enable_admin_wp_login' ) ) {
258 $user = get_user_by( "login", $username );
259 if ( !$user ) {
260 $user = get_user_by( "email", $username );
261 }
262 if ( $user && $this->is_administrator_user( $user ) ) {
263
264 if ( wp_check_password( $password, $user->data->user_pass, $user->ID ) ) {
265 return $user;
266 }
267 }
268 }
269 }else{
270 $error = new WP_Error();
271 if($error_message == 'INVALID_PASSWORD'){
272 $error_message = 'The password is invalid or the user does not have a password.';
273 }
274 $error->add('firebase_error', __( '<strong>ERROR</strong>: '.$error_message ));
275 return $error;
276 }
277 }
278 return $default_user;
279 }
280
281 function mo_firebase_auth_success_message() {
282 $class = "error";
283 $message = get_option('mo_firebase_auth_message');
284 echo "<div class='" . $class . "'> <p>" . $message . "</p></div>";
285 }
286
287 function mo_firebase_auth_error_message() {
288 $class = "updated";
289 $message = get_option('mo_firebase_auth_message');
290 echo "<div class='" . $class . "'><p>" . $message . "</p></div>";
291 }
292
293 function is_administrator_user( $user ) {
294 $userRole = ( $user->roles );
295 if ( ! is_null( $userRole ) && in_array( 'administrator' , $userRole ) ) {
296 return true;
297 }
298 else {
299 return false;
300 }
301 }
302
303 private function mo_firebase_auth_show_success_message() {
304 remove_action( 'admin_notices', array( $this, 'mo_firebase_auth_success_message') );
305 add_action( 'admin_notices', array( $this, 'mo_firebase_auth_error_message') );
306 }
307
308 private function mo_firebase_auth_show_error_message() {
309 remove_action( 'admin_notices', array( $this, 'mo_firebase_auth_error_message') );
310 add_action( 'admin_notices', array( $this, 'mo_firebase_auth_success_message') );
311 }
312
313 function mo_firebase_auth_feedback_request() {
314 mo_firebase_auth_display_feedback_form();
315 }
316
317 private function mo_firebase_authentication_check_empty_or_null( $value ) {
318 if( ! isset( $value ) || empty( $value ) ) {
319 return true;
320 }
321 return false;
322 }
323
324 function mo_firebase_auth_deactivate(){
325
326 if ( isset( $_POST['option'] ) ) {
327
328 if( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "mo_firebase_authentication_change_email" && isset( $_REQUEST['mo_firebase_authentication_change_email_form_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['mo_firebase_authentication_change_email_form_nonce'] ) ), 'mo_firebase_authentication_change_email_form' ) ) {
329 //Adding back button
330 update_option('mo_firebase_authentication_verify_customer', '');
331 update_option('mo_firebase_authentication_registration_status','');
332 update_option('mo_firebase_authentication_new_registration','true');
333 }
334
335 if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "change_miniorange" && isset( $_REQUEST['change_miniorange_form_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['change_miniorange_form_nonce'] ) ), 'change_miniorange_form' ) ) {
336 require_once plugin_dir_path( __FILE__ ) . 'includes/class-firebase-authentication-deactivator.php';
337 MO_Firebase_Authentication_Deactivator::deactivate();
338 return;
339 }
340
341 if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "mo_firebase_authentication_register_customer" && isset( $_REQUEST['mo_fb_register_form_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['mo_fb_register_form_nonce'] ) ), 'mo_fb_register_form' )) { //register the admin to miniOrange
342 //validation and sanitization
343 $email = '';
344 $phone = '';
345 $password = '';
346 $confirmPassword = '';
347 $fname = '';
348 $lname = '';
349 $company = '';
350 if ( $this->mo_firebase_authentication_check_empty_or_null( $_POST['email'] ) || $this->mo_firebase_authentication_check_empty_or_null( $_POST['password'] ) || $this->mo_firebase_authentication_check_empty_or_null( $_POST['confirmPassword'] ) ) {
351 update_option( 'mo_firebase_auth_message', 'All the fields are required. Please enter valid entries.');
352 $this->mo_firebase_auth_show_error_message();
353 return;
354 } else if ( strlen( $_POST['password'] ) < 8 || strlen( $_POST['confirmPassword'] ) < 8) {
355 update_option( 'mo_firebase_auth_message', 'Choose a password with minimum length 8.');
356 $this->mo_firebase_auth_show_error_message();
357 return;
358 } else {
359 $email = sanitize_email( $_POST['email'] );
360 $phone = stripslashes( $_POST['phone'] );
361 $password = stripslashes( $_POST['password'] );
362 $confirmPassword = stripslashes( $_POST['confirmPassword'] );
363 $fname = stripslashes( $_POST['fname'] );
364 $lname = stripslashes( $_POST['lname' ] );
365 $company = stripslashes( $_POST['company'] );
366 }
367
368 update_option( 'mo_firebase_authentication_admin_email', $email );
369 update_option( 'mo_firebase_authentication_admin_phone', $phone );
370 update_option( 'mo_firebase_authentication_admin_fname', $fname );
371 update_option( 'mo_firebase_authentication_admin_lname', $lname );
372 update_option( 'mo_firebase_authentication_admin_company', $company );
373
374 if ( strcmp( $password, $confirmPassword) == 0 ) {
375 update_option( 'password', $password );
376 $customer = new MO_Firebase_Customer();
377 $email = get_option('mo_firebase_authentication_admin_email');
378 $content = json_decode( $customer->check_customer(), true );
379
380 if ( strcasecmp( $content['status'], 'CUSTOMER_NOT_FOUND') == 0 ) {
381 $response = json_decode( $customer->create_customer(), true );
382 if ( strcasecmp( $response['status'], 'SUCCESS' ) != 0 ) {
383 update_option( 'mo_firebase_auth_message', 'Failed to create customer. Try again.' );
384 $this->mo_firebase_auth_show_error_message();
385 }else{
386 update_option( 'mo_firebase_auth_message', 'Your registration is successful. Please login.' );
387 $this->mo_firebase_auth_show_success_message();
388 }
389
390 } elseif ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) {
391 update_option( 'mo_firebase_auth_message', 'Account already exist. Please Login.' );
392 $this->mo_firebase_auth_show_error_message();
393 } else {
394 update_option( 'mo_firebase_auth_message', $content['status'] );
395 $this->mo_firebase_auth_show_success_message();
396 }
397
398
399 } else {
400 update_option( 'mo_firebase_auth_message', 'Passwords do not match.');
401 delete_option('mo_firebase_authentication_verify_customer');
402 $this->mo_firebase_auth_show_error_message();
403 }
404
405 } if( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "mo_firebase_authentication_goto_login" && isset( $_REQUEST['mo_firebase_authentication_goto_login_form_field'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['mo_firebase_authentication_goto_login_form_field'] ) ), 'mo_firebase_authentication_goto_login_form' )) {
406 delete_option( 'mo_firebase_authentication_new_registration' );
407 update_option( 'mo_firebase_authentication_verify_customer', 'true' );
408
409 } if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_enable_firebase_auth' && wp_verify_nonce( $_REQUEST['mo_firebase_auth_enable_field'], 'mo_firebase_auth_enable_form' ) ){
410 update_option( 'mo_enable_firebase_auth', isset( $_POST['mo_enable_firebase_auth'] ) ? (int)filter_var( $_POST['mo_enable_firebase_auth'], FILTER_SANITIZE_NUMBER_INT ) : 0 );
411
412 } else if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_firebase_auth_contact_us' && isset($_REQUEST['mo_firebase_auth_contact_us_field']) && wp_verify_nonce( $_REQUEST['mo_firebase_auth_contact_us_field'], 'mo_firebase_auth_contact_us_form' ) ) {
413 $email = isset( $_POST['mo_firebase_auth_contact_us_email'] ) ? sanitize_email( $_POST['mo_firebase_auth_contact_us_email'] ) : "";
414 $phone = isset( $_POST['mo_firebase_auth_contact_us_phone'] ) ? "+ ".preg_replace( '/[^0-9]/', '', $_POST['mo_firebase_auth_contact_us_phone'] ) : "";
415 //$phone = sanitize_textarea_field($_POST['mo_firebase_auth_contact_us_phone']);
416 $query = isset( $_POST['mo_firebase_auth_contact_us_query'] ) ? sanitize_textarea_field( $_POST['mo_firebase_auth_contact_us_query'] ) : "";
417 if ( $this->mo_firebase_authentication_check_empty_or_null( $email ) || $this->mo_firebase_authentication_check_empty_or_null( $query ) ) {
418 echo '<br><b style=color:red>Please fill up Email and Query fields to submit your query.</b>';
419 } else {
420 $contact_us = new MO_Firebase_contact_us();
421 $submited = $contact_us->mo_firebase_auth_contact_us( $email, $phone, $query );
422 if ( $submited == false ) {
423 update_option( 'mo_firebase_auth_message', 'Your query could not be submitted. Please try again.' );
424 $this->mo_firebase_auth_show_error_message();
425 } else {
426 update_option( 'mo_firebase_auth_message', 'Thanks for getting in touch! We shall get back to you shortly.' );
427 $this->mo_firebase_auth_show_success_message();
428 }
429 }
430
431 } else if( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "mo_firebase_authentication_verify_customer" && isset($_REQUEST['mo_fb_login_form_nonce']) && wp_verify_nonce( $_REQUEST['mo_fb_login_form_nonce'], 'mo_fb_login_form')) {//register the admin to miniOrange
432 //validation and sanitization
433 $email = '';
434 $password = '';
435 if( $this->mo_firebase_authentication_check_empty_or_null( $_POST['email'] ) || $this->mo_firebase_authentication_check_empty_or_null( $_POST['password'] ) ) {
436 update_option( 'mo_firebase_auth_message', 'All the fields are required. Please enter valid entries.');
437 $this->mo_firebase_auth_show_error_message();
438 return;
439 } else{
440 $email = sanitize_email( $_POST['email'] );
441 $password = stripslashes( $_POST['password'] );
442 }
443
444 update_option( 'mo_firebase_authentication_admin_email', $email );
445 update_option( 'password', $password );
446 $customer = new MO_Firebase_Customer();
447 $content = $customer->mo_firebase_auth_get_customer_key();
448 $customerKey = json_decode( $content, true );
449 if( json_last_error() == JSON_ERROR_NONE ) {
450 update_option( 'mo_firebase_authentication_admin_customer_key', $customerKey['id'] );
451 update_option( 'mo_firebase_authentication_admin_api_key', $customerKey['apiKey'] );
452 update_option( 'mo_firebase_authentication_customer_token', $customerKey['token'] );
453 if( isset( $customerKey['phone'] ) )
454 update_option( 'mo_firebase_authentication_admin_phone', $customerKey['phone'] );
455 delete_option( 'password' );
456 update_option( 'mo_firebase_auth_message', 'Customer retrieved successfully');
457 delete_option( 'mo_firebase_authentication_verify_customer' );
458 $this->mo_firebase_auth_show_success_message();
459 } else {
460 update_option( 'mo_firebase_auth_message', 'Invalid username or password. Please try again.');
461 $this->mo_firebase_auth_show_error_message();
462 }
463
464 } else if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_firebase_auth_skip_feedback' && isset($_REQUEST['mo_firebase_auth_skip_feedback_form_nonce']) && wp_verify_nonce( $_REQUEST['mo_firebase_auth_skip_feedback_form_nonce'], 'mo_firebase_auth_skip_feedback_form' ) ) {
465 deactivate_plugins( __FILE__ );
466 update_option( 'mo_firebase_auth_message', 'Plugin deactivated successfully' );
467 $this->mo_firebase_auth_show_success_message();
468
469 } else if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_firebase_auth_feedback' && isset($_REQUEST['mo_firebase_auth_feedback_field']) && wp_verify_nonce( $_REQUEST['mo_firebase_auth_feedback_field'], 'mo_firebase_auth_feedback_form' ) ) {
470 $user = wp_get_current_user();
471 $message = 'Plugin Deactivated:';
472 $deactivate_reason = array_key_exists( 'deactivate_reason_radio', $_POST ) ? $_POST['deactivate_reason_radio'] : false;
473 $deactivate_reason_message = array_key_exists( 'query_feedback', $_POST ) ? $_POST['query_feedback'] : false;
474 if ( $deactivate_reason ) {
475 $message .= $deactivate_reason;
476 if ( isset( $deactivate_reason_message ) ) {
477 $message .= ':' . $deactivate_reason_message;
478 }
479
480 $email = $user->user_email;
481 $contact_us = new MO_Firebase_contact_us();
482 $submited = json_decode( $contact_us->mo_firebase_auth_send_email_alert( $email, $message, "Feedback: WordPress Firebase Authentication" ), true );
483 deactivate_plugins( __FILE__ );
484 update_option( 'mo_firebase_auth_message', 'Thank you for the feedback.' );
485 $this->mo_firebase_auth_show_success_message();
486
487 } else {
488 update_option( 'mo_firebase_auth_message', 'Please Select one of the reasons ,if your reason is not mentioned please select Other Reasons' );
489 $this->mo_firebase_auth_show_error_message();
490 }
491 } else if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_fb_demo_request_form' && isset($_REQUEST['mo_fb_demo_request_field']) && wp_verify_nonce( $_REQUEST['mo_fb_demo_request_field'], 'mo_fb_demo_request_form' ) ) {
492
493 if( current_user_can( 'administrator' ) ){
494
495 $email = sanitize_email( $_POST['mo_fb_demo_request_email'] );
496 $demo_plan = isset($_POST['mo_fb_demo_request_plan']) ? stripslashes( $_POST['mo_fb_demo_request_plan'] ) : '';
497 $query = sanitize_text_field( $_POST['mo_fb_demo_request_usecase'] );
498
499 if( $this->mo_firebase_authentication_check_empty_or_null( $email ) || $this->mo_firebase_authentication_check_empty_or_null( $demo_plan ) || $this->mo_firebase_authentication_check_empty_or_null( $query ) ){
500
501 update_option( 'mo_firebase_auth_message', 'Please fill up usecase, email field and select a demo plan to submit your query.' );
502 $this->mo_firebase_auth_show_error_message();
503 }else{
504 $contact_us = new MO_Firebase_contact_us();
505 $message = '<b>Demo plan:</b> '.$demo_plan.'<br><b>Use-case:</b> '.$query;
506 $submited = $contact_us->mo_firebase_auth_demo_request_mail( $email, $message, 'Demo Request | Firebase Authentication for WP' );
507 if ( $submited == false ) {
508 update_option( 'mo_firebase_auth_message', 'Your query could not be submitted. Please try again.' );
509 $this->mo_firebase_auth_show_error_message();
510 } else {
511 update_option( 'mo_firebase_auth_message', 'Thanks for getting in touch! We shall get back to you shortly.' );
512 $this->mo_firebase_auth_show_success_message();
513 }
514
515 }
516
517 }
518 }
519 }
520 }
521
522 }
523
524 $mo_firebase_authentication_obj = new mo_firebase_authentication_login();