class UserController < ApplicationController
  after_action :refresh_token

  def show
    render_success :ok, json: user_props
  end

  private
    def user_props
      {
        id: current_user.id,
        role: current_user.role,
        associated_id: current_user.user_model_association.id,
        permissions: current_user.permission_users.pluck(:name),
        admin_permissions: AdminPermission.find_or_initialize_by(user: current_user),
        level: current_user.level,
        superuser: current_user.superuser?,
        first_name: current_user.first_name,
        last_name: current_user.last_name,
        avatar: current_user.path_to_photo.to_s,
        email: current_user.email,
        password_changed: current_user&.password_changed&.strftime('%b %d %Y'),
        username: current_user.username,
        google_id: current_user.google_id
      }
    end
end
