diff options
author | Francis Irving <francis@mysociety.org> | 2010-07-20 01:34:15 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-07-20 01:34:15 +0100 |
commit | 847f5a84e296b44ee12ed4185c63559217f8257e (patch) | |
tree | 090747befe187703841034d00accb126710a758e /app/controllers/user_controller.rb | |
parent | 30b6b8cce3cace3b2e1213d1ee53a9ac28855eb3 (diff) |
Button for users to clear their profile photo.
Diffstat (limited to 'app/controllers/user_controller.rb')
-rw-r--r-- | app/controllers/user_controller.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index fd9eb9fbf..854c0d989 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -398,6 +398,22 @@ class UserController < ApplicationController end end + def clear_profile_photo + # check they are logged in (the upload photo option is anyway only available when logged in) + if authenticated_user.nil? + flash[:error] = "You need to be logged in to clear your profile photo." + redirect_to frontpage_url + return + end + + if @user.profile_photo + @user.profile_photo.destroy + end + + flash[:notice] = "You've now cleared your profile photo" + redirect_to user_url(@user) + end + # before they've cropped it def get_draft_profile_photo profile_photo = ProfilePhoto.find(params[:id]) |