Plugin Directory

Changeset 2640310


Ignore:
Timestamp:
12/07/2021 01:20:31 AM (4 years ago)
Author:
code9fair
Message:

Add 2 step verification code blocking time setting.

Location:
code9/trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • code9/trunk/code9.php

    r2629539 r2640310  
    44Plugin URI: https://wordpress.org/plugins/code9/
    55Description: Utility tool for wordpress. 2-step verificatoin code user login.
    6 Version:     1.0.5
     6Version:     1.0.6
    77Author:      Code9Fair
    88Author URI: https://paypal.me/code9fair/
     
    4343    include($GLOBALS['CODE9_PLUGIN_DIR'] . 'plugin/security/api/security_2_step_key_iv_reset.php');
    4444    include($GLOBALS['CODE9_PLUGIN_DIR'] . 'plugin/security/api/security_2_step_update.php');
     45    include($GLOBALS['CODE9_PLUGIN_DIR'] . 'plugin/security/api/security_2_step_blockingtime_update.php');
    4546    include($GLOBALS['CODE9_PLUGIN_DIR'] . 'plugin/security/api/security_anti_brute_force_update.php');
    4647    include($GLOBALS['CODE9_PLUGIN_DIR'] . 'plugin/security/api/security_anti_brute_force_blocked_remove.php');
  • code9/trunk/function/code9_security.php

    r2615536 r2640310  
    145145
    146146                                            if ($_SESSION['code9_security_auth_' . $admin_id . '_attemp'] > 3) {
    147                                                 $_SESSION['code9_security_auth_' . $admin_id . '_block_time'] = time() + 180;
     147                                                $_SESSION['code9_security_auth_' . $admin_id . '_block_time'] = time() + intval(get_option('code9_security_2_step_blockingtime', '180'));
    148148
    149149                                                throw new Exception('Your account has been temporarily locked');
  • code9/trunk/plugin/security/spa/security.js

    r2615536 r2640310  
    2323                        type: "checkbox",
    2424                      })
    25                       .on("change", function () {
    26                         C9_API("security_2_step_update", {
     25                      .on("change", async function () {
     26                        var _response = await C9_API("security_2_step_update", {
    2727                          security_2_step:
    2828                            $(this).prop("checked") === true ? "1" : "0",
    2929                        });
     30
     31                        C9_NOTI(_response.response_text);
    3032                      })
    3133                      .prop(
     
    3840                  ])
    3941                ),
     42              $("<div>")
     43                .attr({
     44                  class: "c9-margin-bottom-small",
     45                })
     46                .html([
     47                  $("<label>").html(__("Blocking time (second)")).attr({
     48                    class: "c9-margin-bottom-small",
     49                  }),
     50                  $("<div>").html(
     51                    $("<input>")
     52                      .attr({
     53                        type: "number",
     54                        class: "c9-margin-bottom-small",
     55                      })
     56                      .val($("#c9-security_2_step_blockingtime-value").val())
     57                      .on("change", async function () {
     58                        var _response = await C9_API(
     59                          "security_2_step_blockingtime_update",
     60                          {
     61                            timeout: $(this).val(),
     62                          }
     63                        );
     64
     65                        C9_NOTI(_response.response_text);
     66                      })
     67                  ),
     68                ]),
    4069              $("<button>")
    4170                .attr({
     
    74103                        type: "checkbox",
    75104                      })
    76                       .on("change", function () {
    77                         C9_API("security_anti_brute_force_update", {
    78                           security_anti_brute_force:
    79                             $(this).prop("checked") === true ? "1" : "0",
    80                         });
     105                      .on("change", async function () {
     106                        var _response = await C9_API(
     107                          "security_anti_brute_force_update",
     108                          {
     109                            security_anti_brute_force:
     110                              $(this).prop("checked") === true ? "1" : "0",
     111                          }
     112                        );
     113
     114                        C9_NOTI(_response.response_text);
    81115                      })
    82116                      .prop(
     
    101135          if (tab_index === 1) {
    102136            (async function () {
    103               var _response = await C9_API("security_anti_brute_force_logs_get");
     137              var _response = await C9_API(
     138                "security_anti_brute_force_logs_get"
     139              );
    104140
    105141              var _data = [];
     
    109145                  var _attacker = data.option_name.split("[]");
    110146
    111                   if(!_attacker[1]) return;
     147                  if (!_attacker[1]) return;
    112148
    113149                  _data.push({
     
    115151                    ip: _attacker[2],
    116152                    amount: data.option_value,
    117                     unblock:  data.option_name
     153                    unblock: data.option_name,
    118154                  });
    119155                });
     
    132168                    name: "unblock",
    133169                    formatter: (data) => {
    134                       return  gridjs.html(
    135                         `<button class="button action c9-anti-brute-force-unblock-button" data-id="${encodeURIComponent(data)}">Unblock</button>`
     170                      return gridjs.html(
     171                        `<button class="button action c9-anti-brute-force-unblock-button" data-id="${encodeURIComponent(
     172                          data
     173                        )}">Unblock</button>`
    136174                      );
    137                     }
    138                    ,
     175                    },
    139176                  },
    140177                ],
     
    154191                  document.getElementById("c9-brute-force-table-container")
    155192                )
    156                 .forceRender().on('ready', function() {
    157                   $('.c9-anti-brute-force-unblock-button').on('click', function() {
    158 
    159                     var _dom = $(this);
    160 
    161                     _anti_brute_force_blocked_remove(_dom.attr('data-id'), function() {
    162                       _dom.replaceWith('<span class="dashicons dashicons-yes"></span>')
    163                     })
    164                   })
     193                .forceRender()
     194                .on("ready", function () {
     195                  $(".c9-anti-brute-force-unblock-button").on(
     196                    "click",
     197                    function () {
     198                      var _dom = $(this);
     199
     200                      _anti_brute_force_blocked_remove(
     201                        _dom.attr("data-id"),
     202                        function () {
     203                          _dom.replaceWith(
     204                            '<span class="dashicons dashicons-yes"></span>'
     205                          );
     206                        }
     207                      );
     208                    }
     209                  );
    165210                });
    166              
    167211            })();
    168212          }
     
    172216  );
    173217
    174   var _anti_brute_force_blocked_remove = async function(id, callback) {
    175     var _response = await C9_API('security_anti_brute_force_blocked_remove', {id: decodeURIComponent(id)});
    176 
    177     console.log(_response);
     218  var _anti_brute_force_blocked_remove = async function (id, callback) {
     219    var _response = await C9_API("security_anti_brute_force_blocked_remove", {
     220      id: decodeURIComponent(id),
     221    });
     222
     223    C9_NOTI(_response.response_text);
     224
    178225    callback();
    179226  };
  • code9/trunk/plugin/security/spa/security.php

    r2615536 r2640310  
    55  <div id="c9-security-tab-container"></div>
    66  <input type="hidden" value="<?php echo get_option('code9_security_2_step', '0');?>" id="c9-security_2_step-value" />
     7  <input type="hidden" value="<?php echo get_option('code9_security_2_step_blockingtime', '180');?>" id="c9-security_2_step_blockingtime-value" />
    78  <input type="hidden" value="<?php echo get_option('code9_security_anti_brute_force', '0');?>" id="c9-security_security_anti_brute_force-value" />
    89</div>
  • code9/trunk/readme.txt

    r2629539 r2640310  
    55Requires at least: 4.1
    66Tested up to: 5.8
    7 Stable tag: 1.0.5
     7Stable tag: 1.0.6
    88Requires PHP: 5.6.4
    99License: GPLv2
     
    6363= 1.0.5 =
    6464* Show data on log tabs when attacker try to login more than 2 attempts.
     65= 1.0.6 =
     66* Add 2 step verification code blocking time setting.
Note: See TracChangeset for help on using the changeset viewer.