summaryrefslogtreecommitdiff
path: root/lib/generators/nifty/authentication/templates/users_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generators/nifty/authentication/templates/users_controller.rb')
-rw-r--r--lib/generators/nifty/authentication/templates/users_controller.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/generators/nifty/authentication/templates/users_controller.rb b/lib/generators/nifty/authentication/templates/users_controller.rb
new file mode 100644
index 0000000..2faed00
--- /dev/null
+++ b/lib/generators/nifty/authentication/templates/users_controller.rb
@@ -0,0 +1,32 @@
+class <%= user_plural_class_name %>Controller < ApplicationController
+ before_filter :login_required, :except => [:new, :create]
+
+ def new
+ @<%= user_singular_name %> = <%= user_class_name %>.new
+ end
+
+ def create
+ @<%= user_singular_name %> = <%= user_class_name %>.new(params[:<%= user_singular_name %>])
+ if @<%= user_singular_name %>.save
+ <%- unless options[:authlogic] -%>
+ session[:<%= user_singular_name %>_id] = @<%= user_singular_name %>.id
+ <%- end -%>
+ redirect_to root_url, :notice => "Thank you for signing up! You are now logged in."
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @<%= user_singular_name %> = current_<%= user_singular_name %>
+ end
+
+ def update
+ @<%= user_singular_name %> = current_<%= user_singular_name %>
+ if @<%= user_singular_name %>.update_attributes(params[:<%= user_singular_name %>])
+ redirect_to root_url, :notice => "Your profile has been updated."
+ else
+ render :edit
+ end
+ end
+end