typo_web_service.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:

Ajax

开发平台:

Others

  1. class TypoWebService < ActionWebService::Base
  2.   attr_accessor :controller
  3.   def initialize(controller)
  4.     @controller = controller
  5.   end
  6.   def this_blog
  7.     controller.send(:this_blog)
  8.   end
  9.   protected
  10.   def authenticate(name, args)
  11.     method = self.class.web_service_api.api_methods[name]
  12.     # Coping with backwards incompatibility change in AWS releases post 0.6.2
  13.     begin
  14.       h = method.expects_to_hash(args)
  15.       raise "Invalid login" unless @user=User.authenticate(h[:username], h[:password])
  16.     rescue NoMethodError
  17.       username, password = method[:expects].index(:username=>String), method[:expects].index(:password=>String)
  18.       raise "Invalid login" unless @user = User.authenticate(args[username], args[password])
  19.     end
  20.   end
  21. end