Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
in a couchapp's entry page,this bookmarklet opens a form into which you can type your login and password and start a session.
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>';
function login(event) {
event.returnValue = false;
var form = document.getElementById('loginForm');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
};'POST', '/_session', true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send('name=' + + '&password=' + form.password.value);
"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": ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment