Skip to content

Instantly share code, notes, and snippets.

@lefnire
Created June 27, 2013 16:41
Show Gist options
  • Save lefnire/5878074 to your computer and use it in GitHub Desktop.
Save lefnire/5878074 to your computer and use it in GitHub Desktop.
derbyauth with username
diff --git a/components/login/index.coffee b/components/login/index.coffee
index 4c29aa4..2760e6e 100644
--- a/components/login/index.coffee
+++ b/components/login/index.coffee
@@ -2,6 +2,7 @@ utils = require('../../utils.coffee')
jQuery = undefined
exports.init = (model) ->
+ model.set "optionsUsername", model.parent().parent().get("_derbyAuth.options.username") or "username"
exports.create = (model, dom) ->
#jQuery = window?.jQuery or require('../../vendor/jquery-1.10.1.min.js')
diff --git a/components/login/index.html b/components/login/index.html
index 1ad9b28..2c24fb9 100644
--- a/components/login/index.html
+++ b/components/login/index.html
@@ -3,7 +3,7 @@
<form id="derby-auth-login" action='/login' method='post'>
<div class="control-group {#if .errors.username}error{/}">
- <input type='text' name="username" placeholder="Username" x-bind="blur:usernameBlur" value="{.username}"/>
+ <input type='text' name="{{optionsUsername}}" placeholder="Username" x-bind="blur:usernameBlur" value="{.username}"/>
<span class="help-inline">{.errors.username}</span>
</div>
diff --git a/middleware.coffee b/middleware.coffee
index bbb4425..c9571ab 100644
--- a/middleware.coffee
+++ b/middleware.coffee
@@ -136,6 +136,9 @@ module.exports = (strategies, options) ->
# After passport does it's thing, let's use it's req.user object & req helper methods to setup our app
expressApp.use (req, res, next) ->
model = req.getModel()
+
+ model.set "_derbyAuth.options.username", options.passport.username
+
model.set "_session.flash", req.flash() # set any error / success messages
model.set "_session.userId", req.session.userId
if req.isAuthenticated()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment