2009-10-07 20:46:40 -04:00
|
|
|
class PasswordsController < ApplicationController
|
2009-10-27 19:26:40 -04:00
|
|
|
include Devise::Controllers::Helpers
|
|
|
|
|
|
|
|
before_filter :require_no_authentication
|
2009-10-07 20:46:40 -04:00
|
|
|
|
2009-10-17 11:10:15 -04:00
|
|
|
# GET /resource/password/new
|
2009-10-07 20:46:40 -04:00
|
|
|
def new
|
2009-10-27 19:31:12 -04:00
|
|
|
build_resource
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|
|
|
|
|
2009-10-17 11:10:15 -04:00
|
|
|
# POST /resource/password
|
2009-10-07 20:46:40 -04:00
|
|
|
def create
|
2009-10-10 10:05:56 -04:00
|
|
|
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
2009-10-12 07:37:28 -04:00
|
|
|
|
2009-10-10 08:32:51 -04:00
|
|
|
if resource.errors.empty?
|
2009-10-12 07:37:28 -04:00
|
|
|
set_flash_message :success, :send_instructions
|
2009-10-11 22:24:57 -04:00
|
|
|
redirect_to new_session_path(resource_name)
|
2009-10-07 20:46:40 -04:00
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-11-10 15:55:13 -05:00
|
|
|
# GET /resource/password/edit?reset_password_token=abcdef
|
2009-10-07 20:46:40 -04:00
|
|
|
def edit
|
2009-10-10 10:05:56 -04:00
|
|
|
self.resource = resource_class.new
|
2009-10-18 07:14:52 -04:00
|
|
|
resource.reset_password_token = params[:reset_password_token]
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|
|
|
|
|
2009-10-17 11:10:15 -04:00
|
|
|
# PUT /resource/password
|
2009-10-07 20:46:40 -04:00
|
|
|
def update
|
2009-10-10 10:05:56 -04:00
|
|
|
self.resource = resource_class.reset_password!(params[resource_name])
|
2009-10-17 11:10:15 -04:00
|
|
|
|
2009-10-10 08:32:51 -04:00
|
|
|
if resource.errors.empty?
|
2009-10-12 07:37:28 -04:00
|
|
|
set_flash_message :success, :updated
|
2009-11-19 08:16:31 -05:00
|
|
|
sign_in_and_redirect(resource_name, resource)
|
2009-10-07 20:46:40 -04:00
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|