firebase-authentication-admin-display.php
132 lines
| 1 | <?php |
| 2 | |
| 3 | function mo_firebase_auth_page_ui() { |
| 4 | ?> |
| 5 | <html> |
| 6 | <body> |
| 7 | <div class="mo_firebase_auth_success_container" style="display:none;" id="mo_firebase_auth_success_container"> |
| 8 | <div class="alert alert-success alert-dismissable" id="mo_firebase_auth_success_alert" data-fade="3000"> |
| 9 | <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> |
| 10 | Configurations saved successfully. |
| 11 | </div> |
| 12 | </div> |
| 13 | <div class="mo_firebase_auth_error_container" style="display:none;" id="mo_firebase_auth_error_container"> |
| 14 | <div class="alert alert-danger alert-dismissable" id="mo_firebase_auth_error_alert" data-fade="3000"> |
| 15 | <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> |
| 16 | Please enter required fields. |
| 17 | </div> |
| 18 | </div> |
| 19 | <div style="margin-left:15px;overflow:hidden"> |
| 20 | <div class="row" style="margin:15px"> |
| 21 | <img width="30px" src="<?php echo dirname(plugin_dir_url( __FILE__ ));?>/images/logo.png"><h5>miniOrange Firebase Authentication</h5> |
| 22 | </div> |
| 23 | <div class="row"> |
| 24 | <div class="col-md-8"> |
| 25 | <div> |
| 26 | <div class="mo_firebase_auth_card" style="width:90%" > |
| 27 | <form action="" method="post" id="mo_enable_firebase_auth_form"> |
| 28 | <?php wp_nonce_field('mo_firebase_auth_enable_form','mo_firebase_auth_enable_field'); ?> |
| 29 | <div style="display:inline"><div style="display:inline-block;padding:0px 10px 10px 0px"><strong>Enable Firebase Authentication:</strong></div> |
| 30 | <div style="display:inline-block"><label class="mo_firebase_auth_switch"> |
| 31 | <input value="1" name="mo_enable_firebase_auth" type="checkbox" id="mo_enable_firebase_auth" <?php echo get_option('mo_enable_firebase_auth') ? 'checked' : '' ?>> |
| 32 | <span class="mo_firebase_auth_slider round"></span> |
| 33 | <input type="hidden" name="option" value="mo_enable_firebase_auth"> |
| 34 | </label> |
| 35 | </div> |
| 36 | </div> |
| 37 | </form> |
| 38 | <form action="" method="post" id="mo_firebase_auth_form"> |
| 39 | <?php wp_nonce_field('mo_firebase_auth_config_form','mo_firebase_auth_config_field'); ?> |
| 40 | <div style="padding:5px;"></div>Allow login with |
| 41 | <input style="margin-left: 5px;"type="radio" name="disable_wordpress_login" id="disable_wordpress_login" <?php if(get_option('mo_enable_firebase_auth') == false){ echo '';}else {echo get_option('mo_firebase_auth_disable_wordpress_login') ? '' : 'checked';} ?> value="0"onclick="mo_firebase_auth_hideDiv();">Both Firebase and WordPress |
| 42 | <span style="padding-right:10px" ></span> |
| 43 | <input type="radio" name="disable_wordpress_login" id="disable_wordpress_login" <?php if(get_option('mo_enable_firebase_auth') == false){ echo '';}else {echo get_option('mo_firebase_auth_disable_wordpress_login') ? 'checked' : '';} ?> value="1"onclick="mo_firebase_auth_showDiv();">Only Firebase |
| 44 | <div style="padding:5px;"></div> |
| 45 | <div style="<?php if(get_option('mo_firebase_auth_disable_wordpress_login') == 1) echo "display: block";else echo "display: none";?>"id="mo_firebase_auth_enable_admin_wp_login_div"> |
| 46 | <p>Enabling Firebase login will restrict logins with only Firebase credentials and won't allow WP login. <b>Please enable this only after you have successfully tested your configuration</b> as the default WordPress login will stop working. |
| 47 | </p> |
| 48 | <input type="checkbox" id="mo_firebase_auth_enable_admin_wp_login" name="mo_firebase_auth_enable_admin_wp_login" value="1" <?php checked((esc_attr(get_option('mo_firebase_auth_enable_admin_wp_login')) === false) || (esc_attr(get_option('mo_firebase_auth_enable_admin_wp_login')) == 1));?> /> Allow Administrators to use WordPress login <div class="mo-firebase-auth-tooltip">🛈<div class="mo-firebase-auth-tooltip-text mo-tt-right">Selecting this option will only allow Wordpress Administrators to log in.</div> </div> |
| 49 | <br> |
| 50 | </div> |
| 51 | <br> |
| 52 | <h6><font color="#FF0000">*</font><font color="#000000">Project Id</font> <div class="mo-firebase-auth-tooltip">🛈<div class="mo-firebase-auth-tooltip-text mo-tt-right">collect project Id from your firebase project</div> </div></h6> |
| 53 | <input style="width:60%"type="text" id="project_id" name="projectid" value= "<?php echo get_option( 'mo_firebase_auth_project_id' ); ?>" placeholder="Enter Project Id.." required=""> |
| 54 | <br><br> |
| 55 | <h6><font color="#FF0000">*</font><font color="#000000">API Key</font> <div class="mo-firebase-auth-tooltip">🛈<div class="mo-firebase-auth-tooltip-text mo-tt-right">collect API key from your firebase project</div> </div></h6> |
| 56 | <input style="width:60%"type="text" id="api_key" name="apikey" value="<?php echo get_option( 'mo_firebase_auth_api_key' ); ?>" placeholder="Enter your API Key.." required=""> |
| 57 | <br> |
| 58 | <br> |
| 59 | <input type="submit" class="btn btn-primary" style="width:170px;height:40px" name="verify_user" value=" Save Configuration" id = "mo_auth_configure_button"onclick="showAlert();"> |
| 60 | </form> |
| 61 | </div> |
| 62 | </div> |
| 63 | <div> |
| 64 | <div class="mo_firebase_auth_card" style="width:90%" > |
| 65 | <h4 style="margin-bottom:30px">Test Authentication</h4> |
| 66 | <form name="test_configuration_form" id="mo_firebasetestconfig" method="post" target="firebasetestconfig"> |
| 67 | <?php wp_nonce_field('mo_firebase_auth_test_config_form','mo_firebase_auth_test_config_field'); ?> |
| 68 | <input type="hidden" name="option" value="mo_firebase_auth_test_configuration"> |
| 69 | <font color="#FF0000">* </font><input type="text" id="test_username" name="test_username" value="" placeholder="Username" style="margin-bottom:30px;width:35%;" required=""> <br> |
| 70 | <font color="#FF0000">* </font><input type="password" id="test_password" name="test_password" value="" placeholder="Password" style="margin-bottom:30px;width:35%;" required=""> <br> |
| 71 | <input type="hidden" id="test_check_field" name="test_check_field" value="test_check_true"> |
| 72 | <input type="submit" class="btn btn-primary" id="mo_firebase_auth_test_config_button" style="width:170px;height:40px" name="test_configuration" value="Test Authentication" <?php if( ! get_option( 'mo_firebase_auth_project_id' ) && ! get_option( 'mo_firebase_auth_api_key' ) ) echo 'disabled' ?> > |
| 73 | </form> |
| 74 | </div> |
| 75 | </div> |
| 76 | </div> |
| 77 | <div class="col-md-4"> |
| 78 | <div class="mo_firebase_auth_card" style="width:90%" > |
| 79 | <h4 style="margin-bottom:30px">Contact us</h4> |
| 80 | <p class="mo_firebase_auth_contact_us_p"><b>Need any help?<br>Just send us a query so we can help you.</b></p><br> |
| 81 | <form action="" method="POST"> |
| 82 | <?php wp_nonce_field('mo_firebase_auth_contact_us_form','mo_firebase_auth_contact_us_field'); ?> |
| 83 | <input type="hidden" name="option" value="mo_firebase_auth_contact_us"> |
| 84 | <div class="form-group"> |
| 85 | <input type="email" placeholder="Enter email here" class="form-control" name="mo_firebase_auth_contact_us_email" id="mo_firebase_auth_contact_us_email" required> |
| 86 | </div> |
| 87 | <div class="form-group"> |
| 88 | <input type="tel" id="mo_firebase_auth_contact_us_phone" pattern="[\+]\d{11,14}|[\+]\d{1,4}[\s]\d{9,10}" placeholder="Enter phone here" class="form-control" name="mo_firebase_auth_contact_us_phone"> |
| 89 | </div> |
| 90 | <div class="form-group"> |
| 91 | <textarea class="form-control" onkeypress="mo_firebase_auth_contact_us_valid_query(this)" onkeyup="mo_firebase_auth_contact_us_valid_query(this)" onblur="mo_firebase_auth_contact_us_valid_query(this)" name="mo_firebase_auth_contact_us_query" placeholder="Enter query here" rows="5" id="mo_firebase_auth_contact_us_query" required></textarea> |
| 92 | </div> |
| 93 | <input type="submit" class="btn btn-primary" style="width:130px;height:40px" value="Submit"> |
| 94 | </form> |
| 95 | <br> |
| 96 | <p class="mo_firebase_auth_contact_us_p"><b>If you want custom features in the plugin, just drop an email at<br><a href="mailto:info@xecurify.com">info@xecurify.com</a></b></p> |
| 97 | </div> |
| 98 | </div> |
| 99 | </div> |
| 100 | </div> |
| 101 | <script> |
| 102 | jQuery("#mo_firebase_auth_contact_us_phone").intlTelInput(); |
| 103 | function mo_firebase_auth_contact_us_valid_query(f) { |
| 104 | !(/^[a-zA-Z?,.\(\)\/@ 0-9]*$/).test(f.value) ? f.value = f.value.replace( |
| 105 | /[^a-zA-Z?,.\(\)\/@ 0-9]/, '') : null; |
| 106 | } |
| 107 | |
| 108 | jQuery("#mo_firebase_auth_test_config_button").on("click", function(event) { |
| 109 | var test_username = document.forms["test_configuration_form"]["test_username"].value; |
| 110 | var test_password = document.forms["test_configuration_form"]["test_password"].value; |
| 111 | if( test_username == "" || test_password == "" ){ |
| 112 | return; |
| 113 | } |
| 114 | event.preventDefault(); |
| 115 | let url = "<?php echo site_url(); ?>/?mo_action=firebaselogin&test=true"; |
| 116 | jQuery("#mo_firebasetestconfig").attr("action", url); |
| 117 | let newwindow = window.open("about:blank", 'firebasetestconfig', 'location=yes,height=700,width=600,scrollbars=yes,status=yes'); |
| 118 | jQuery("#mo_firebasetestconfig").submit(); |
| 119 | }); |
| 120 | function mo_firebase_auth_showDiv(){ |
| 121 | document.getElementById("mo_firebase_auth_enable_admin_wp_login_div").style.display = "block"; |
| 122 | } |
| 123 | function mo_firebase_auth_hideDiv(){ |
| 124 | document.getElementById("mo_firebase_auth_enable_admin_wp_login_div").style.display = "none"; |
| 125 | } |
| 126 | |
| 127 | </script> |
| 128 | <?php |
| 129 | |
| 130 | } |
| 131 | |
| 132 | ?> |