mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
auth provider safe destroy
This commit is contained in:
parent
82838ceb6e
commit
a1fd69f309
@ -31,8 +31,11 @@ class API::AuthProvidersController < API::ApiController
|
||||
|
||||
def destroy
|
||||
authorize AuthProvider
|
||||
@provider.destroy
|
||||
head :no_content
|
||||
if @provider.safe_destroy
|
||||
head :no_content
|
||||
else
|
||||
render json: @provider.errors, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def mapping_fields
|
||||
@ -56,7 +59,7 @@ class API::AuthProvidersController < API::ApiController
|
||||
params.require(:auth_provider).permit(:name, :providable_type)
|
||||
elsif params['auth_provider']['providable_type'] == OAuth2Provider.name
|
||||
params.require(:auth_provider).permit(:name, :providable_type, providable_attributes: [
|
||||
:id, :base_url, :token_endpoint, :authorization_endpoint, :profile_url, :client_id, :client_secret,
|
||||
:id, :base_url, :token_endpoint, :authorization_endpoint, :logout_endpoint, :profile_url, :client_id, :client_secret,
|
||||
o_auth2_mappings_attributes: [
|
||||
:id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, :_destroy,
|
||||
transformation: [:type, :format, :true_value, :false_value, mapping: [:from, :to]]
|
||||
|
@ -80,6 +80,14 @@ class AuthProvider < ActiveRecord::Base
|
||||
providable.profile_url
|
||||
end
|
||||
|
||||
def safe_destroy
|
||||
if self.status != 'active'
|
||||
destroy
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def set_initial_state
|
||||
# the initial state of a new AuthProvider will be 'pending', except if there is currently
|
||||
|
Loading…
x
Reference in New Issue
Block a user