]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/client_application.rb
Restore templating to embed.js
[rails.git] / app / models / client_application.rb
index b1d3d945e2e79146a079daaf4004c53dcdf35696..e1358028d98ae6fe7197b922cc081194528e759c 100644 (file)
@@ -1,4 +1,4 @@
-require 'oauth'
+require "oauth"
 
 class ClientApplication < ActiveRecord::Base
   belongs_to :user
@@ -9,9 +9,9 @@ class ClientApplication < ActiveRecord::Base
 
   validates_presence_of :name, :url, :key, :secret
   validates_uniqueness_of :key
-  validates_format_of :url, :with => /\Ahttp(s?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i
-  validates_format_of :support_url, :with => /\Ahttp(s?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i, :allow_blank => true
-  validates_format_of :callback_url, :with => /\A[a-z][a-z0-9.+-]*:\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i, :allow_blank => true
+  validates_format_of :url, :with => %r{\Ahttp(s?)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i
+  validates_format_of :support_url, :with => %r{\Ahttp(s?)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i, :allow_blank => true
+  validates_format_of :callback_url, :with => %r{\A[a-z][a-z0-9.+-]*://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i, :allow_blank => true
 
   before_validation :generate_keys, :on => :create
 
@@ -19,11 +19,7 @@ class ClientApplication < ActiveRecord::Base
 
   def self.find_token(token_key)
     token = OauthToken.find_by_token(token_key, :include => :client_application)
-    if token && token.authorized?
-      token
-    else
-      nil
-    end
+    token if token && token.authorized?
   end
 
   def self.verify_request(request, options = {}, &block)