Skip to content

Commit

Permalink
reset password, login page, start on people/edit
Browse files Browse the repository at this point in the history
  • Loading branch information
gerad committed Jul 30, 2010
1 parent 5444ade commit 19470be
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
5 changes: 3 additions & 2 deletions models/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

var http = require('http'),
parse = require('url').parse,
queryString = require('querystring')
queryString = require('querystring'),
sys = require('sys')

function merge(a, b) {
var ret = {};
for (var k in a) ret[k] = a[k];
for (var k in a) ret[k] = b[k];
for (var k in b) ret[k] = b[k];
return ret;
}

Expand Down
44 changes: 23 additions & 21 deletions nodeko.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,29 @@ get '/teams/:teamId/invite/:personId', ->
# TODO flash "Sent a new invitation to $@person.email"
@redirect '/teams/' + team.id()

# # # # edit person
# # # get '/people/:id/edit', ->
# # # Person.first @req.param('id'), (error, person) =>
# # # @ensurePermitted person, =>
# # # @person: person
# # # @render 'people/edit.html.haml'
# # #
# edit person
get '/people/:id/edit', ->
Person.first @req.param('id'), (error, person) =>
@ensurePermitted person, =>
@person = person
@render 'people/edit.html.haml'

# sign in
get '/login', ->
@person = new Person()
@render 'login.html.haml'

# reset password
post '/reset_password', ->
Person.first { email: @req.param('email') }, (error, person) =>
# TODO assumes xhr
unless person?
@res.send 'Email not found', 404
else
person.resetPassword =>
@res.send 'OK', 200


# # # # update person
# # # app.put '/people/:id', ->
# # # Person.first @req.param('id'), (error, person) =>
Expand All @@ -211,10 +227,6 @@ get '/teams/:teamId/invite/:personId', ->
# # # person.save (error, resp) =>
# # # @redirectToTeam person
# # #
# # # # sign in
# # # get '/login', ->
# # # @person: new Person()
# # # @render 'login.html.haml'
# # #
# # # app.post '/login', ->
# # # Person.login @req.params.post, (error, person) =>
Expand All @@ -240,16 +252,6 @@ get '/teams/:teamId/invite/:personId', ->
# # # @logout =>
# # # @redirect '/'
# # #
# # # # reset password
# # # app.post '/reset_password', ->
# # # Person.first { email: @req.param('email') }, (error, person) =>
# # # # TODO assumes xhr
# # # unless person?
# # # @respond 404, 'Email not found'
# # # else
# # # person.resetPassword =>
# # # @respond 200, 'OK'
# # #
# # # get '/*.js', (file) ->
# # # try
# # # @render "${file}.js.coffee", { layout: false }
Expand Down
8 changes: 4 additions & 4 deletions views/login.html.haml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
%h1.ribbon Sign in

!= this.partial('errors.html.haml')
!= partial('errors.html.haml', { locals: { ctx: ctx } })

%form{ method: 'POST', action: 'login' }
%input{ type: 'hidden', name: 'return_to', value: this.param('return_to') }
%input{ type: 'hidden', name: 'return_to', value: ctx.req.param('return_to') }
%p
%label{ for: 'email' } Email
%br
%input{ type: 'email', name: 'email', id: 'email', value: this.person.email || this.param('email'), autofocus: true }
%input{ type: 'email', name: 'email', id: 'email', value: ctx.person.email || ctx.req.param('email'), autofocus: true }
%p
%label{ for: 'password' } Password
%br
%input{ type: 'password', name: 'password', id: 'password', value: this.param('password') }
%input{ type: 'password', name: 'password', id: 'password', value: ctx.req.param('password') }
%p
%input{ type: 'checkbox', name: 'remember', id: 'remember', checked: true }
%label{ for: 'remember' } Stay logged in
Expand Down
2 changes: 1 addition & 1 deletion views/reset_password.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%h1 Forgot your password?

!= this.partial('errors.html.haml')
!= partial('errors.html.haml', { locals: { ctx: ctx } })

%form.reset_password{ method: 'POST', action: 'reset_password' }
%p
Expand Down

0 comments on commit 19470be

Please sign in to comment.