initial commit from appmail
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
class CredentialsController < ApplicationController
|
||||
|
||||
include WithinOrganization
|
||||
|
||||
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
|
||||
before_action { params[:id] && @credential = @server.credentials.find_by_key!(params[:id]) }
|
||||
|
||||
def index
|
||||
@credentials = @server.credentials.order(:name).to_a
|
||||
end
|
||||
|
||||
def new
|
||||
@credential = @server.credentials.build
|
||||
end
|
||||
|
||||
def create
|
||||
@credential = @server.credentials.build(params.require(:credential).permit(:type, :name, :hold))
|
||||
if @credential.save
|
||||
redirect_to_with_json [organization, @server, :credentials]
|
||||
else
|
||||
render_form_errors 'new', @credential
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @credential.update(params.require(:credential).permit(:name, :hold))
|
||||
redirect_to_with_json [organization, @server, :credentials]
|
||||
else
|
||||
render_form_errors 'edit', @credential
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@credential.destroy
|
||||
redirect_to_with_json [organization, @server, :credentials]
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user