Skip to content
This repository has been archived by the owner on Apr 15, 2021. It is now read-only.

Commit

Permalink
prepwork for saving user to db
Browse files Browse the repository at this point in the history
  • Loading branch information
carloseberhardt committed May 7, 2012
1 parent 044164b commit 071b0b4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions app.coffee
Expand Up @@ -58,6 +58,7 @@ app.get "/logout", routes.site.logout
app.get "/login", routes.site.login
app.get "/nodes/:id", routes.site.nodes
app.get "/users/:id", ensureAuthenticated, routes.users.show
app.get "/users", routes.users.signup
app.post "/users", routes.users.create
app.get "/auth/google", passport.authenticate("google")
app.get "/auth/google/return", passport.authenticate("google",
Expand Down
5 changes: 5 additions & 0 deletions models/user.coffee
Expand Up @@ -43,6 +43,11 @@ User.get = (callback) ->
return callback(err) if err
callback null, new User(node)

User.getByEmail = (callback) ->
db.getIndexedNode index, property, value, (err, node) ->
return callback(err) if err
callback null, new User(node)

User.create = (data, callback) ->
node = db.createNode(data)
user = new User(node)
Expand Down
7 changes: 6 additions & 1 deletion routes/users.coffee
@@ -1,8 +1,13 @@
User = require("../models/user")

exports.create = (req, res, next) ->
User.create
name: req.body["name"]
email: req.body["email"]
, (err, user) ->
return next(err) if err
res.redirect "/"
res.redirect "/"

exports.signup = (req, res) ->
res.render "signup",
user: req.user
6 changes: 4 additions & 2 deletions views/index.jade
Expand Up @@ -35,8 +35,10 @@ div.container
a.btn.btn-primary.btn-large Learn more »
div.row
div.span4
h2 Message 1
p Do excepteur pariatur brooklyn kogi. Biodiesel wes anderson qui swag, quis aliqua wolf terry richardson vegan ea placeat gentrify nisi brunch. Portland sustainable accusamus nulla sed. Non wolf ex nostrud letterpress. Authentic commodo dolor nisi thundercats williamsburg kale chips, nesciunt synth ullamco cosby sweater. Aliquip freegan pariatur, beard four loko polaroid single-origin coffee locavore forage squid ea vice food truck. Squid pop-up chambray labore, reprehenderit fixie hella banh mi proident ethical bicycle rights id umami narwhal.
h2 User Info
p= user.displayName
p= user.identifier
p= user.emails[0].value
a.btn(href='#') View details »
div.span4
h2 Message 2
Expand Down

0 comments on commit 071b0b4

Please sign in to comment.