Commit 7103af5f

mo k <mo@mokhan.ca>
2012-06-25 16:31:55
update registration controller so that it never changes the users password.
1 parent 5a4441a
Changed files (3)
app/controllers/registrations_controller.rb
@@ -7,22 +7,11 @@ class RegistrationsController < Devise::RegistrationsController
   def update
     @user = current_user
     @user.interest_ids = params[:user][:interest_ids] ||= []
-    if params[:user][:password].blank? 
-      if @user.update_without_password(params[:user])
-        sign_in @user, :bypass => true
-        flash[:notice]= 'Your settings have been updated successfully!'
-        redirect_to profiles_mine_path
-      else
-        render "edit"
-      end
+    if @user.update_without_password(params[:user])
+      sign_in @user, :bypass => true
+      redirect_to profiles_mine_path, :notice =>'Your settings have been updated successfully!'
     else
-      if @user.update_with_password(params[:user])
-        sign_in @user, :bypass => true
-        flash[:notice]= 'Your settings have been updated successfully!'
-        redirect_to profiles_mine_path
-      else
-        render "edit"
-      end
+      render "edit"
     end
   end
 end
app/controllers/settings_controller.rb
@@ -11,9 +11,9 @@ class SettingsController < ApplicationController
     @user.password=params[:user][:password]
     if @user.save
       sign_in @user, :bypass => true
-      redirect_to profiles_mine_path, notice: 'Your password has been changed.' 
+      redirect_to profiles_mine_path, notice: 'Your password has been changed!'
     else
-      flash[:alert] = "Invalid password, must be at least 6 charactors." 
+      flash[:alert] = "Invalid password, must be at least 6 charactors."
       redirect_to :back
     end
   end
app/views/registrations/edit.html.erb
@@ -45,20 +45,6 @@
             <%= f.label :email, :class => "control-label"  %>
             <div class="controls"> <%= f.email_field :email, :class => "input-xlarge"  %> </div>
           </div>
-          <!--
-          <div class="control-group">
-            <%= f.label :password, :class => "control-label" %> 
-            <div class="controls"> <%= f.password_field :password, :class => "input-xlarge"  %> </div>
-          </div>
-          <div class="control-group">
-            <%= f.label :password_confirmation, "Confirm password", :class => "control-label" %> 
-            <div class="controls"> <%= f.password_field :password_confirmation, :class => "input-xlarge" %> </div>
-          </div>
-          <div class="control-group">
-            <%= f.label :current_password, :class => "control-label" %> 
-            <div class="controls"> <%= f.password_field :current_password, :class => "input-xlarge" %> </div>
-          </div>
-          -->
           <div class="control-group">
             <%= f.label :city, :class => 'control-label' %>
             <div class="controls"> <%= f.text_field :city, :class => "input-xlarge" %> </div>
@@ -100,11 +86,11 @@
     </div>
     <div class="span3">
       <%= form_for(@user, :url => settings_change_password_path(@user), :html => { :method => :post }) do |f| %>
-        <%= f.label :password, "New password" %>
+        <%= f.label :password, "New Password" %>
         <%= f.password_field :password %>
-        <%= f.label :password_confirmation, "Confirm new password" %>
+        <%= f.label :password_confirmation, "Confirm New Password" %>
         <%= f.password_field :password_confirmation %>
-        <%= f.submit "Change my password" %>
+        <%= f.submit "Change My Password", :class=>"btn btn-primary" %>
       <% end %>
     </div>
   </div>