update client key encryption
This commit is contained in:
@@ -24,11 +24,10 @@ class ClientsController < ApplicationController
|
||||
# POST /clients
|
||||
# POST /clients.json
|
||||
def create
|
||||
@client = Client.new(client_params)
|
||||
@client = Client.new(client_params)
|
||||
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
|
||||
key=cipher.random_key
|
||||
secrect_key= Base64.encode64(key)
|
||||
@client.secrect_key=secrect_key
|
||||
secrect_key = cipher.random_key
|
||||
@client.secrect_key = secrect_key
|
||||
|
||||
respond_to do |format|
|
||||
if @client.save
|
||||
@@ -68,7 +67,7 @@ class ClientsController < ApplicationController
|
||||
# DELETE /clients/1.json
|
||||
def destroy
|
||||
message="Client was successfully destroyed."
|
||||
|
||||
|
||||
find_batch=Batch.find_by_id(@client.id)
|
||||
if !find_batch.nil?
|
||||
message='Unable to delete client named '+ @client.name.to_s+'.'
|
||||
@@ -90,6 +89,6 @@ class ClientsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def client_params
|
||||
params.require(:client).permit(:name,:email, :phone, :address,:location_code)
|
||||
params.require(:client).permit(:name,:email, :phone, :address,:location_code)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user