Skip to content

Commit

Permalink
Added forgot password view and email template
Browse files Browse the repository at this point in the history
Added forgot password sent dat to user model
  • Loading branch information
BRIMIL01 committed Mar 28, 2011
1 parent 7f722f5 commit f810199
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
8 changes: 8 additions & 0 deletions controllers/user_handling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ class Rstatus
haml :reset_username
end
end

get '/forgot_password' do
haml :"forgot_password"
end

post '/forgot_password' do
User.where(:email => params[:email])
end
end
8 changes: 8 additions & 0 deletions models/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def self.send_signup_notification(recipient, token)
:body => render_haml_template("signup", {:token => token}),
:via => :smtp, :via_options => Rstatus::PONY_VIA_OPTIONS)
end

def self.send_forgot_password_notification(recipient, token)
Pony.mail(:to => recipient,
:subject => "Reset your rstat.us password",
:from => "[email protected]",
:body => render_haml_template("forgot_password", {:token => token}),
:via => :smtp, :via_options => Rstatus::PONY_VIA_OPTIONS)
end

private

Expand Down
1 change: 1 addition & 0 deletions models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def at_replies(opts)

attr_accessor :password
key :hashed_password, String
key :password_reset_sent, Date, :default => nil

def password=(pass)
@password = pass
Expand Down
2 changes: 1 addition & 1 deletion rstatus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Rstatus
haml :index, :layout => false
end
end

post '/signup' do
u = User.create(:email => params[:email],
:status => "unconfirmed")
Expand Down
9 changes: 9 additions & 0 deletions views/forgot_password.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%h2 Forgot Password

%p Just provide us with the email address on your account and we will send you an email with a link to reset your password.

%form{:action => "/forgot_password", :method => "POST"}
%label{:for => "email" } Email:
%input{:type => "text", :name => "email", :id => "email"}
%br/
%input{:type => "submit", :value => "Send "}
7 changes: 7 additions & 0 deletions views/notifier/forgot_password.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To reset your password for rstat.us please click on the link below.

http://rstat.us/reset_password/#{token}

Please be aware that this link will only be valid for 2 days.

\- The rstat.us site Robot

0 comments on commit f810199

Please sign in to comment.