Custom password requirements for forgot password / password recovery - Parse.com

I have an iOS app and using Parse.com I can allow the user to reset them if they forget it using the Parse.com API. The problem is that when the user resets their password, none of the criteria for the password can be enforced (or at least I haven't found a way yet) or even another field to verify that you are entering the correct password. I am wondering if anyone has a solution.

My situation is accurate: when you enter the reset password, can I apply minimum criteria like 1 uppercase letter, 1 number and 1 lowercase letter? Also, you have a password confirmation box below.

I have tried client side JS validation with no success. I have included the blocks of code below. Thank!!!!

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;
    }
  });

});

//-->

      

+3


source to share





All Articles