Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
d08d7c3a1b
4 changed files with 59 additions and 2 deletions
|
|
@ -21,12 +21,25 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@user = current_user
|
@user = current_user
|
||||||
|
|
||||||
data = clean_hash params[:user]
|
data = clean_hash params[:user]
|
||||||
prep_image_url(data)
|
prep_image_url(data)
|
||||||
|
|
||||||
|
|
||||||
|
params[:user].delete(:password) if params[:user][:password].blank?
|
||||||
|
params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
|
||||||
|
|
||||||
|
if params[:user][:password] && params[:user][:password_confirmation]
|
||||||
|
if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])
|
||||||
|
flash[:notice] = "Password Changed"
|
||||||
|
else
|
||||||
|
flash[:error] = "Password Change Failed"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
@user.update_profile data
|
@user.update_profile data
|
||||||
respond_with(@user, :location => root_url)
|
redirect_to edit_user_path(@user)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def public
|
def public
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,13 @@
|
||||||
%p
|
%p
|
||||||
= p.label :last_name
|
= p.label :last_name
|
||||||
= p.text_field :last_name, :value => @profile.last_name
|
= p.text_field :last_name, :value => @profile.last_name
|
||||||
|
%p
|
||||||
|
= f.label :password
|
||||||
|
= f.text_field :password
|
||||||
|
%p
|
||||||
|
= f.label :password_confirmation
|
||||||
|
= f.text_field :password_confirmation
|
||||||
|
|
||||||
|
|
||||||
#submit_block
|
#submit_block
|
||||||
= link_to t('.cancel'), root_path
|
= link_to t('.cancel'), root_path
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ if File.exists?(File.expand_path("./config/fb_config.yml"))
|
||||||
FB_APP_ID = fb_config['fb_app_id']
|
FB_APP_ID = fb_config['fb_app_id']
|
||||||
HOST = fb_config['host']
|
HOST = fb_config['host']
|
||||||
FACEBOOK = true
|
FACEBOOK = true
|
||||||
|
else
|
||||||
|
FACEBOOK = false
|
||||||
end
|
end
|
||||||
# Initialize the rails application
|
# Initialize the rails application
|
||||||
Diaspora::Application.initialize!
|
Diaspora::Application.initialize!
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,42 @@ describe UsersController do
|
||||||
|
|
||||||
@user.person.profile.image_url.should == image_url
|
@user.person.profile.image_url.should == image_url
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'should allow the user to update their password' do
|
||||||
|
it 'should change a users password ' do
|
||||||
|
old_password = @user.encrypted_password
|
||||||
|
|
||||||
|
put("update", :id => @user.id, "user"=> {"password" => "foobaz", 'password_confirmation' => "foobaz","profile"=>
|
||||||
|
{"image_url" => "",
|
||||||
|
"last_name" => @user.person.profile.last_name,
|
||||||
|
"first_name" => @user.person.profile.first_name}})
|
||||||
|
|
||||||
|
@user.reload
|
||||||
|
@user.encrypted_password.should_not == old_password
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not change a password if they do not match' do
|
||||||
|
old_password = @user.encrypted_password
|
||||||
|
put("update", :id => @user.id, "user"=> {"password" => "foobarz", 'password_confirmation' => "not_the_same","profile"=>
|
||||||
|
{"image_url" => "",
|
||||||
|
"last_name" => @user.person.profile.last_name,
|
||||||
|
"first_name" => @user.person.profile.first_name}})
|
||||||
|
@user.reload
|
||||||
|
@user.encrypted_password.should == old_password
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it 'should not update if the password fields are left blank' do
|
||||||
|
|
||||||
|
old_password = @user.encrypted_password
|
||||||
|
put("update", :id => @user.id, "user"=> {"password" => "", 'password_confirmation' => "","profile"=>
|
||||||
|
{"image_url" => "",
|
||||||
|
"last_name" => @user.person.profile.last_name,
|
||||||
|
"first_name" => @user.person.profile.first_name}})
|
||||||
|
@user.reload
|
||||||
|
@user.encrypted_password.should == old_password
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue