cours0708/P5B/ruby/3dossmanno_annuaire/app/controllers/users_controller.rb

31 lines
795 B
Ruby
Raw Permalink Normal View History

2008-11-25 21:11:16 +00:00
class UsersController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# render new.rhtml
def new
end
def create
cookies.delete :auth_token
reset_session
@user = User.new(params[:user])
@user.save!
self.current_user = @user
redirect_back_or_default('/')
flash[:notice] = "Thanks for signing up!"
rescue ActiveRecord::RecordInvalid
render :action => 'new'
end
def activate
self.current_user = params[:activation_code].blank? ? :false : User.find_by_activation_code(params[:activation_code])
if logged_in? && !current_user.activated?
current_user.activate
flash[:notice] = "Signup complete!"
end
redirect_back_or_default('/')
end
end