Update user avatar in LDAP

This commit is contained in:
Râu Cao
2023-09-06 19:02:07 +02:00
parent 64d09cfb7f
commit 50c63d5c38
3 changed files with 27 additions and 4 deletions

View File

@@ -10,9 +10,9 @@ class User < ApplicationRecord
#
has_one_attached :avatar do |attachable|
attachable.variant :small, resize_to_fill: [64, 64]
attachable.variant :medium, resize_to_fill: [256, 256]
attachable.variant :large, resize_to_fill: [512, 512]
attachable.variant :small, resize_to_fill: [64, 64], convert: :jpeg
attachable.variant :medium, resize_to_fill: [256, 256], convert: :jpeg
attachable.variant :large, resize_to_fill: [512, 512], convert: :jpeg
end
#
@@ -167,6 +167,11 @@ class User < ApplicationRecord
@display_name ||= ldap_entry[:display_name]
end
def avatar_base64(variant: :large)
Base64.strict_encode64 avatar.variant(variant).processed.download
end
def services_enabled
ldap_entry[:service] || []
end