about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-16 18:29:52 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-16 18:29:52 +0100
commit9cb690c70690bcebba69d3b66fb0b90e798d477d (patch)
treef282ae79be96067138b53adf6603ea8d5663e8a7 /app/controllers
parent786397e15dde5500deb1d324e7e62ec13bb61178 (diff)
Access tokens no longer expire, case-insensitive local username validation, as well as case-insensitive Webfinger look-up
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/xrd_controller.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/xrd_controller.rb b/app/controllers/xrd_controller.rb
index 2946e9999..fa67b2baa 100644
--- a/app/controllers/xrd_controller.rb
+++ b/app/controllers/xrd_controller.rb
@@ -6,7 +6,7 @@ class XrdController < ApplicationController
   end
 
   def webfinger
-    @account = Account.find_by!(username: username_from_resource, domain: nil)
+    @account = Account.find_local!(username_from_resource)
     @canonical_account_uri = "acct:#{@account.username}@#{Rails.configuration.x.local_domain}"
     @magic_key = pem_to_magic_key(@account.keypair.public_key)
   rescue ActiveRecord::RecordNotFound
@@ -21,10 +21,10 @@ class XrdController < ApplicationController
   end
 
   def username_from_resource
-    if params[:resource].start_with?('acct:')
-      params[:resource].split('@').first.gsub('acct:', '')
+    if resource_param.start_with?('acct:')
+      resource_param.split('@').first.gsub('acct:', '')
     else
-      url = Addressable::URI.parse(params[:resource])
+      url = Addressable::URI.parse(resource_param)
       url.path.gsub('/users/', '')
     end
   end
@@ -43,4 +43,8 @@ class XrdController < ApplicationController
 
     (["RSA"] + [modulus, exponent].map { |n| Base64.urlsafe_encode64(n) }).join('.')
   end
+
+  def resource_param
+    params.require(:resource)
+  end
 end