Commit 5128a88
Changed files (2)
app
controllers
models
app/controllers/clients_controller.rb
@@ -5,6 +5,12 @@ class ClientsController < ApplicationController
def create
@client = Client.create!(transform(secure_params))
render status: :created, formats: :json
+ rescue ActiveRecord::RecordInvalid => error
+ json = {
+ error: :invalid_redirect_uri,
+ error_description: error.record.errors.full_messages.join(' ')
+ }
+ render json: json, status: :bad_request
end
private
app/models/client.rb
@@ -8,6 +8,7 @@ class Client < ApplicationRecord
attribute :redirect_uris, :string, array: true
enum token_endpoint_auth_method: { client_secret_none: 0, client_secret_post: 1, client_secret_basic: 2 }
+ validates :redirect_uris, presence: true, format: { with: URI_REGEX }
validates :jwks_uri, format: { with: URI_REGEX }
validates :logo_uri, format: { with: URI_REGEX }
validates :name, presence: true