mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Fix importing Immich and Photoprism geolocation data for non-admin users
This commit is contained in:
parent
8fefcb9091
commit
86fd2311f9
4 changed files with 48 additions and 4 deletions
|
|
@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
# 0.24.2 - 2025-02-15
|
||||||
|
|
||||||
|
## Fixed
|
||||||
|
|
||||||
|
- Fixed a bug where background jobs to import Immich and Photoprism geolocation data data could not be created by non-admin users.
|
||||||
|
|
||||||
# 0.24.1 - 2025-02-13
|
# 0.24.1 - 2025-02-13
|
||||||
|
|
||||||
## Custom map tiles
|
## Custom map tiles
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
class Settings::BackgroundJobsController < ApplicationController
|
class Settings::BackgroundJobsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :authenticate_admin!
|
before_action :authenticate_admin!, unless: lambda {
|
||||||
|
%w[start_immich_import start_photoprism_import].include?(params[:job_name])
|
||||||
|
}
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@queues = Sidekiq::Queue.all
|
@queues = Sidekiq::Queue.all
|
||||||
|
|
@ -13,7 +15,15 @@ class Settings::BackgroundJobsController < ApplicationController
|
||||||
|
|
||||||
flash.now[:notice] = 'Job was successfully created.'
|
flash.now[:notice] = 'Job was successfully created.'
|
||||||
|
|
||||||
redirect_to settings_background_jobs_path, notice: 'Job was successfully created.'
|
redirect_path =
|
||||||
|
case params[:job_name]
|
||||||
|
when 'start_immich_import', 'start_photoprism_import'
|
||||||
|
imports_path
|
||||||
|
else
|
||||||
|
settings_background_jobs_path
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to redirect_path, notice: 'Job was successfully created.'
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ RSpec.describe '/settings/background_jobs', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is authenticated' do
|
context 'when user is authenticated' do
|
||||||
before { sign_in create(:user) }
|
let(:user) { create(:user, admin: false) }
|
||||||
|
|
||||||
|
before { sign_in user }
|
||||||
|
|
||||||
context 'when user is not an admin' do
|
context 'when user is not an admin' do
|
||||||
it 'redirects to root page' do
|
it 'redirects to root page' do
|
||||||
|
|
@ -26,6 +28,32 @@ RSpec.describe '/settings/background_jobs', type: :request do
|
||||||
expect(response).to redirect_to(root_url)
|
expect(response).to redirect_to(root_url)
|
||||||
expect(flash[:notice]).to eq('You are not authorized to perform this action.')
|
expect(flash[:notice]).to eq('You are not authorized to perform this action.')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when job name is start_immich_import' do
|
||||||
|
it 'redirects to imports page' do
|
||||||
|
post settings_background_jobs_url, params: { job_name: 'start_immich_import' }
|
||||||
|
|
||||||
|
expect(response).to redirect_to(imports_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'enqueues a new job' do
|
||||||
|
expect do
|
||||||
|
post settings_background_jobs_url, params: { job_name: 'start_immich_import' }
|
||||||
|
end.to have_enqueued_job(EnqueueBackgroundJob)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when job name is start_photoprism_import' do
|
||||||
|
it 'redirects to imports page' do
|
||||||
|
get settings_background_jobs_url, params: { job_name: 'start_photoprism_import' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'enqueues a new job' do
|
||||||
|
expect do
|
||||||
|
post settings_background_jobs_url, params: { job_name: 'start_photoprism_import' }
|
||||||
|
end.to have_enqueued_job(EnqueueBackgroundJob)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is an admin' do
|
context 'when user is an admin' do
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ RSpec.describe '/settings/users', type: :request do
|
||||||
it 'redirects to sign in page' do
|
it 'redirects to sign in page' do
|
||||||
post settings_users_url, params: { user: valid_attributes }
|
post settings_users_url, params: { user: valid_attributes }
|
||||||
|
|
||||||
expect(response).to redirect_to(new_user_session_url)
|
expect(response).to redirect_to(root_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue