Created
February 1, 2017 18:55
-
-
Save lenart/e3bd2abe179606108998f444f8e1b282 to your computer and use it in GitHub Desktop.
Sample form for resetting password on parse-server (parseFrameURL)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
parseFrameURL should point to this document. | |
Once the form is submitted it will: | |
- redirect to passwordResetSuccess if everything goes well | |
- redirect to invalidLink if data is invalid (eg. missing or invalid token, wrong email) | |
--> | |
<html> | |
<head></head> | |
<body> | |
<h1>Reset Your Password<span id='app'></span></h1> | |
<noscript>We apologize, but resetting your password requires javascript</noscript> | |
<div class='error' id='error'></div> | |
<form id='form' action='#' method='POST'> | |
<label>New Password</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> | |
<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://my-parse-server.com/1'; | |
var id = "my-parse-app-id"; | |
document.getElementById('form').setAttribute('action', base + '/apps/' + id + '/request_password_reset'); | |
document.getElementById('username').value = urlParams['username']; | |
document.getElementById('token').value = urlParams['token']; | |
if (urlParams['error']) { | |
document.getElementById('error').appendChild(document.createTextNode(urlParams['error'])); | |
} | |
} | |
//--> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment