Skip to content

Instantly share code, notes, and snippets.

@sebastianrothbucher
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save sebastianrothbucher/98615d0aa09eca5674f6 to your computer and use it in GitHub Desktop.

Select an option

Save sebastianrothbucher/98615d0aa09eca5674f6 to your computer and use it in GitHub Desktop.
Couch Login form (sep. public DB)
{
"_id": "_design/login",
"redir": "/somepath",
"usage": "Deploy (i.e. add as doc - verbatim) to a DB that is public, call as /dbname/_design/login/_show/login?redir?/someredirpath (where the query param is optional and falls back to 'redir' in the design doc. Advantage: Browsers (esp. iPhone) can remember credentials",
"shows": {
"login": "function(doc, req){return \"<html><head><meta name=\\\"viewport\\\" content=\\\"width=device-width, initial-scale=1\\\" /></head><body><form action=\\\"/_session?next=\"+(req.query.redir?req.query.redir:this.redir)+\"\\\" method=\\\"POST\\\">User: <input type=\\\"text\\\" name=\\\"name\\\" /><br />Pass: <input type=\\\"password\\\" name=\\\"password\\\" /><br /><input type=\\\"submit\\\" /></form></body></html>\"}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment