Skip to content
Snippets Groups Projects
Commit ad1ea726 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

refactor some methods

parent 455abd25
No related branches found
No related tags found
No related merge requests found
......@@ -39,8 +39,8 @@ class ApplicationController < ActionController::API
private
def allow_client_application
app = Application.find_by_application_id(request.headers["PortalMEC-AppID"])
user_not_authorized if (app.try(:domain) != request.domain) || app.nil?
app = Application.find_or_initialize_by(application_id: request.headers["PortalMEC-AppID"].to_s)
user_not_authorized if app.domain != request.domain
end
def user_not_authorized
......
......@@ -8,6 +8,7 @@ class Application < ActiveRecord::Base
private
def generate_application_id
self.application_id = SecureRandom.uuid
@application_id = SecureRandom.uuid.to_s
generate_application_id if self.class.find_by_application_id(@application_id)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment