mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
delete avatars before changing to a new one
This commit is contained in:
parent
f88707b159
commit
adfa20f606
1
Gemfile
1
Gemfile
@ -16,6 +16,7 @@ gem 'filesize'
|
||||
gem 'paperclip'
|
||||
gem 'rmagick'
|
||||
gem 'image_processing'
|
||||
gem 'active_storage_validations'
|
||||
|
||||
# Authentication
|
||||
gem 'devise'
|
||||
|
||||
@ -79,6 +79,8 @@ GEM
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
active_record_union (1.3.0)
|
||||
activerecord (>= 4.0)
|
||||
active_storage_validations (0.8.5)
|
||||
rails (>= 5.2.0)
|
||||
activejob (6.0.2)
|
||||
activesupport (= 6.0.2)
|
||||
globalid (>= 0.3.6)
|
||||
@ -1470,6 +1472,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
active_storage_validations
|
||||
acts_as_list
|
||||
animate-rails
|
||||
authority
|
||||
|
||||
@ -67,6 +67,7 @@ class RegistrationsController < Devise::RegistrationsController
|
||||
def attach_avatar
|
||||
return unless account_update_params.key?('avatar')
|
||||
|
||||
current_user.avatar.purge
|
||||
current_user.avatar.attach(account_update_params.fetch('avatar', nil))
|
||||
end
|
||||
|
||||
|
||||
@ -58,6 +58,7 @@ class UsersController < ApplicationController
|
||||
|
||||
report_user_deletion_to_slack(current_user)
|
||||
|
||||
current_user.avatar.purge
|
||||
current_user.really_destroy!
|
||||
|
||||
redirect_to(root_path, notice: 'Your account has been deleted. We will miss you greatly!')
|
||||
|
||||
@ -52,10 +52,24 @@ class User < ApplicationRecord
|
||||
has_many :notice_dismissals, dependent: :destroy
|
||||
|
||||
has_one_attached :avatar
|
||||
validates :avatar, attached: true,
|
||||
content_type: {
|
||||
in: ['image/png', 'image/jpg', 'image/jpeg', 'image/gif'],
|
||||
message: 'must be a PNG, JPG, JPEG, or GIF'
|
||||
},
|
||||
dimension: {
|
||||
width: { max: 1000 },
|
||||
height: { max: 1000 },
|
||||
message: 'must be smaller than 1000x1000 pixels'
|
||||
},
|
||||
size: {
|
||||
less_than: 500.kilobytes,
|
||||
message: "can't be larger than 500KB"
|
||||
}
|
||||
|
||||
def contributable_universes
|
||||
@user_contributable_universes ||= begin
|
||||
# todo email confirmation needs to happy for data safety / privacy (only verified emails)
|
||||
# todo email confirmation needs to happen for data safety / privacy (only verified emails)
|
||||
contributor_ids = Contributor.where('email = ? OR user_id = ?', self.email, self.id).pluck(:universe_id)
|
||||
|
||||
Universe.where(id: contributor_ids)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user