忘记密码/密码恢复的自定义密码要求 - Parse.com

时间:2014-11-12 06:21:05

标签: parse-platform passwords forgot-password password-checker

我有一个iOS应用程序,并且使用Parse.com,我可以允许用户重置他们,如果他们忘记了它使用Parse.com API。问题在于,当用户重置密码时,没有任何密码标准可以执行(或者至少我还没有找到办法)或甚至是另一个字段来验证您输入的密码是否正确密码。我想知道是否有人有解决方案。

我的确切情况:当您输入重置密码时,我可以应用最小条件,例如1个大写字母,1个数字和1个小写字母吗?此外,请在下面有一个验证密码字段。

我试图做客户端JS验证但没有成功。我已经包含了下面的代码块。谢谢!!!!

HTML

<div class="row">
<div class="medium-6 medium-offset-3 small-10 small-offset-1 columns">
  <form id='form' action='#' method='POST'>
    <label>New Password for <span id='username_label'></span></label>
    <input name="new_password" type="password" />
    <input name='utf-8' type='hidden' value='✓' />
    <input name="username" id="username" type="hidden" />
    <input name="token" id="token" type="hidden" />
    <button>Change Password</button>
  </form>
</div>

JS

<script language='javascript' type='text/javascript'>
<!--
window.onload = function() {
  var urlParams = {};
  (function () {
      var pair, // Really a match. Index 0 is the full match; 1 & 2 are the key & val.
          tokenize = /([^&=]+)=?([^&]*)/g,
          // decodeURIComponents escapes everything but will leave +s that should be ' '
          re_space = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); },
          // Substring to cut off the leading '?'
          querystring = window.location.search.substring(1);

      while (pair = tokenize.exec(querystring))
         urlParams[re_space(pair[1])] = re_space(pair[2]);
  })();

  var base = 'https://www.parse.com';
  var id = urlParams['id'];
  document.getElementById('form').setAttribute('action', base + '/apps/' + id + '/request_password_reset');
  document.getElementById('username').value = urlParams['username'];
  document.getElementById('username_label').appendChild(document.createTextNode(urlParams['username']));

  document.getElementById('token').value = urlParams['token'];
  if (urlParams['error']) {
    document.getElementById('error').appendChild(document.createTextNode(urlParams['error']));
  }
  if (urlParams['app']) {
    document.getElementById('app').appendChild(document.createTextNode(' for ' + urlParams['app']));
  }

}

$(function() {
$('#form').submit(function() {
    if (document.getElementById('new_password').length == 2)
    {
      // something is wrong
      alert('There is a problem with the first field');
      return false;
    }
    else {
      return true;
    }
  });

});

//-->

0 个答案:

没有答案
相关问题