class-mo-firebase-authentication-advsettings.php
5 years ago
class-mo-firebase-authentication-config.php
5 years ago
class-mo-firebase-authentication-hooks.php
5 years ago
class-mo-firebase-authentication-licensing_plans.php
5 years ago
class-mo-firebase-authentication-config.php
103 lines
| 1 | <?php |
| 2 | |
| 3 | class Mo_Firebase_Authentication_Admin_Config { |
| 4 | |
| 5 | public static function mo_firebase_authentication_config() { |
| 6 | ?> |
| 7 | <!-- <div id="mo_firebase_authentication_support_layout" class="mo_firebase_authentication_support_layout"> --> |
| 8 | <div class="row"> |
| 9 | <div class="col-md-12"> |
| 10 | <div> |
| 11 | <div class="mo_firebase_auth_card" style="width:100%" > |
| 12 | <form action="" method="post" id="mo_enable_firebase_auth_form"> |
| 13 | <?php wp_nonce_field('mo_firebase_auth_enable_form','mo_firebase_auth_enable_field'); ?> |
| 14 | <!-- <div style="display:inline"><div style="display:inline-block;padding:0px 10px 10px 0px"><strong>Enable Firebase Authentication:</strong></div> --> |
| 15 | <div style="display:inline-block"><label class="mo_firebase_auth_switch"> |
| 16 | <input value="1" name="mo_enable_firebase_auth" type="checkbox" id="mo_enable_firebase_auth" <?php echo get_option('mo_enable_firebase_auth') ? 'checked' : '' ?>> |
| 17 | <span class="mo_firebase_auth_slider round"></span> |
| 18 | <input type="hidden" name="option" value="mo_enable_firebase_auth"> |
| 19 | </label> |
| 20 | </div> |
| 21 | <div style="display:inline"><div style="display:inline-block;padding:0px 10px 10px 0px"><strong>Enable Firebase Authentication</strong></div> |
| 22 | <span style="float: right;">[ |
| 23 | <a href="https://plugins.miniorange.com/wordpress-firebase-authentication#firebaseauthentication" target="_blank">How to configure?</a> ]</span> |
| 24 | </div> |
| 25 | </form> |
| 26 | <form action="" method="post" id="mo_firebase_auth_form"> |
| 27 | <?php wp_nonce_field('mo_firebase_auth_config_form','mo_firebase_auth_config_field'); ?> |
| 28 | <div style="padding:5px;"></div><strong>Allow users to login with :</strong><br> |
| 29 | <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 |
| 30 | <span style="padding-right:10px" ></span> |
| 31 | <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 |
| 32 | <div style="padding:5px;"></div> |
| 33 | <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"> |
| 34 | <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. |
| 35 | </p> |
| 36 | <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> |
| 37 | <br> |
| 38 | </div> |
| 39 | <br> |
| 40 | <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> |
| 41 | <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=""> |
| 42 | <br><br> |
| 43 | <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> |
| 44 | <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=""> |
| 45 | <br> |
| 46 | <br> |
| 47 | <input type="submit" class="btn btn-primary" style="width:170px;height:40px" name="verify_user" value=" Save Configuration" id = "mo_auth_configure_button"> |
| 48 | </form> |
| 49 | </div> |
| 50 | </div> |
| 51 | <div> |
| 52 | <div class="mo_firebase_auth_card" id ="test_authentication" style="width:100%" > |
| 53 | <h4 style="margin-bottom:30px">Test Authentication</h4> |
| 54 | <form name="test_configuration_form" id="mo_firebasetestconfig" method="post" target="firebasetestconfig"> |
| 55 | <?php wp_nonce_field('mo_firebase_auth_test_config_form','mo_firebase_auth_test_config_field'); ?> |
| 56 | <input type="hidden" name="option" value="mo_firebase_auth_test_configuration"> |
| 57 | <font color="#FF0000">* </font><input type="text" id="test_username" name="test_username" value="" placeholder="Username" style="margin-bottom:30px;width:35%;" required=""> <br> |
| 58 | <font color="#FF0000">* </font><input type="password" id="test_password" name="test_password" value="" placeholder="Password" style="margin-bottom:30px;width:35%;" required=""> <br> |
| 59 | <input type="hidden" id="test_check_field" name="test_check_field" value="test_check_true"> |
| 60 | <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' ?> > |
| 61 | </form> |
| 62 | </div> |
| 63 | </div> |
| 64 | <div class="mo_firebase_auth_card" style="width:100%" > |
| 65 | <h4 style="margin-bottom:30px">Attribute Mapping <small style="color: #FF0000;font-size: 60%"><a href="admin.php?page=mo_firebase_authentication&tab=licensing_plans">[PREMIUM]</a></small></h4> |
| 66 | <form name="mo_firebase_attr_mapping_form" id="mo_firebase_attr_mapping_form" method="post"> |
| 67 | <input type="hidden" name="option" value="mo_firebase_attr_mapping"> |
| 68 | <table class="mo_firebase_attr_table"> |
| 69 | <tr><td><strong><span class="mo_premium_feature">*</span>Username Attribute:</strong></td> |
| 70 | <td><input type="text" id="mo_firebase_username" name="username_attr" value="" placeholder="Username Attribute Name" class="mo_table_textbox" disabled></td></tr> |
| 71 | |
| 72 | <tr><td><span class="mo_premium_feature"></span><strong>Email Attribute:</strong></td> |
| 73 | <td><input type="text" id="mo_firebase_email" name="email_attr" value="" placeholder="Email Attribute Name" class="mo_table_textbox" disabled></td></tr> |
| 74 | </table><br> |
| 75 | <input type="submit" class="btn btn-primary" id="mo_firebase_save_attr_mapping_button" style="width:170px;height:40px" name="save_settings" value="Save Settings" disabled> |
| 76 | </form> |
| 77 | </div> |
| 78 | </div> |
| 79 | </div> |
| 80 | <script> |
| 81 | jQuery("#mo_firebase_auth_test_config_button").on("click", function(event) { |
| 82 | var test_username = document.forms["test_configuration_form"]["test_username"].value; |
| 83 | var test_password = document.forms["test_configuration_form"]["test_password"].value; |
| 84 | if( test_username == "" || test_password == "" ){ |
| 85 | return; |
| 86 | } |
| 87 | event.preventDefault(); |
| 88 | let url = "<?php echo site_url(); ?>/?mo_action=firebaselogin&test=true"; |
| 89 | jQuery("#mo_firebasetestconfig").attr("action", url); |
| 90 | let newwindow = window.open("about:blank", 'firebasetestconfig', 'location=yes,height=700,width=600,scrollbars=yes,status=yes'); |
| 91 | jQuery("#mo_firebasetestconfig").submit(); |
| 92 | }); |
| 93 | function mo_firebase_auth_showDiv(){ |
| 94 | document.getElementById("mo_firebase_auth_enable_admin_wp_login_div").style.display = "block"; |
| 95 | } |
| 96 | function mo_firebase_auth_hideDiv(){ |
| 97 | document.getElementById("mo_firebase_auth_enable_admin_wp_login_div").style.display = "none"; |
| 98 | } |
| 99 | |
| 100 | </script> |
| 101 | <?php |
| 102 | } |
| 103 | } |