1
0
Fork 0
oldhaven/app/controllers/user_controller.rb

27 lines
818 B
Ruby

require 'digest'
class UserController < ApplicationController
@@secret_key
def auth
# Defining secret key dependent on hostname
@@secret_key = request.host == 'beathaven.org' ? 'sdgwSbl3nNE4ZxafuPrp' : 's5zyjb693z6uV4rbhEyc'
@res = {}
unless params[:expire].nil? or params[:mid].nil? or params[:secret].nil? or params[:sid].nil? or params[:sig].nil?
# Calculating hash
hash = 'expire='+ params[:expire] +'mid='+ params[:mid] +'secret='+ params[:secret] +'sid='+ params[:sid] + @@secret_key
hash_md5 = Digest::MD5.hexdigest(hash)
if Digest::MD5.hexdigest(hash) == params[:sig]
@res[:status] = 'hello'
else
@res[:status] = 'bad signature'
end
else
@res[:status] = 'bad params'
end
render :json => @res
end
end