Skip to content
Snippets Groups Projects
Commit 4ca0bd3c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Fix user profile update, show user gravatar

parent f3ef59c4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -207,3 +207,18 @@ h3 {
font-weight: normal;
color: #666;
}
.profile-holder {
position: relative;
img {
position: absolute;
top: -2px;
width: 24px;
@include border-radius(4px);
}
span {
margin-left: 35px;
}
}
Loading
Loading
@@ -16,9 +16,20 @@ class UsersController < ApplicationController
end
 
def update
current_user.update_attributes(params[:user])
user_params = params[:user]
 
redirect_to :back
if current_user.valid_password?(user_params.delete(:current_password))
user_params.delete(:password) if user_params[:password].blank?
user_params.delete(:password_confirmation) if user_params[:password_confirmation].blank?
current_user.update_attributes(user_params)
redirect_to :back
else
redirect_to :back, alert: 'Current password is invalid'
end
end
 
def destroy
Loading
Loading
Loading
Loading
@@ -2,4 +2,10 @@ module ApplicationHelper
def loader_html
image_tag 'loader.gif'
end
def gravatar_icon(user_email = '', size = 40)
gravatar_url = 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
user_email.strip!
sprintf gravatar_url, hash: Digest::MD5.hexdigest(user_email.downcase), size: size
end
end
Loading
Loading
@@ -20,20 +20,26 @@
= link_to 'Users', users_path
%li
= link_to 'Background Jobs', resque_path
%ul.nav.pull-right
- if current_user
%li
= link_to edit_user_path(current_user) do
%i.icon-user.icon-white
= current_user.email
.profile-holder
= image_tag gravatar_icon(current_user.email, 24)
%span= current_user.email
%li
= link_to 'Logout', destroy_user_session_path, class: "logout", method: :delete
= link_to destroy_user_session_path, class: "logout", method: :delete do
%i.icon-signout
Logout
- else
%li
= link_to 'Login', new_user_session_path
.container-fluid
- if alert || notice
%small
= alert || notice
%hr
- if alert
.alert= alert
- if notice
.alert.alert-info= notice
= yield
.right
.padded
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment