Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is action in the controller
- #Reset password
- def reset
- @user = User.find_by_reset_code(params[:reset_code])
- if request.post?
- respond_to do |format|
- if @user.update_attributes(params[:user]) #@user.update_attributes(:password => params[:password], :password_confirmation => params[:password_confirmation])
- logger.debug("******** Success")
- self.current_user = @user
- @user.delete_reset_code
- flash[:notice] = "Your password was reset successfully."
- format.html { redirect_to "/login" }
- else
- logger.debug("******** Fail")
- format.html { render :layout => "login_template", :action => "reset" }
- end
- end
- end
- end
- #And here is the view
- <div id="reset_box">
- <h1>Reset your password</h1>
- <p class="instructions">Type a new password for <%= @user.email %>.</p>
- <%= custom_error_messages_for @user %>
- <% form_for :user do |f| %>
- <p>
- <label for="password">Password</label><br />
- <%= f.password_field :password %>
- </p>
- <p>
- <label for="password">Confirm Password</label><br />
- <%= f.password_field :password_confirmation %>
- </p>
- <p class="reset_submit">
- <%= submit_tag 'Reset', :class => "login_button" %> or <%= link_to "Cancel", "login" %>
- </p>
- <% end %>
- <br clear="all"/>
- </div>
Add Comment
Please, Sign In to add comment