Last active
August 29, 2015 14:03
-
-
Save fiatjaf/b8d4f3b0b76f4e493e46 to your computer and use it in GitHub Desktop.
in a couchapp's entry page,this bookmarklet opens a form into which you can type your login and password and start a session.
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
var form = '<div style="position:absolute;left:50%;top:50%;margin-left:-150px;margin-top:-100px;width:300px;height:200px;"><form id="loginForm"><input placeholder="nome" name="name"><input placeholder="senha" type="password" name="password"><button onclick="login(event)">OK</button></form></div>'; | |
document.write(form); | |
function login(event) { | |
event.preventDefault(); | |
event.returnValue = false; | |
var form = document.getElementById('loginForm'); | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function () { | |
if (xhr.readyState === 4) { | |
location.reload(); | |
} | |
}; | |
xhr.open('POST', '/_session', true); | |
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
xhr.send('name=' + form.name.value + '&password=' + form.password.value); | |
}; |
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
{ | |
"name": "Login to CouchApp", | |
"description": "Open a form to login to the current CouchApp (if you're seeing the 'not authorized to this db' page)", | |
"link": "https://gist.github.com/fiatjaf/b8d4f3b0b76f4e493e46" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment