From d7da0fa3de050b11e8aaaa8aa8d438a04db943bd Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Wed, 22 Jun 2011 00:44:19 +0400 Subject: [PATCH] Settings draft --- app/controllers/user_controller.rb | 60 +++++++++++++--------- public/images/icns/settings.png | Bin 0 -> 3137 bytes public/index.html | 6 ++- public/javascripts/beathaven/ajax.js | 9 ++++ public/javascripts/beathaven/pages.js | 6 +++ public/javascripts/beathaven/search.js | 3 +- public/javascripts/beathaven/session.js | 17 +++++- public/javascripts/beathaven/settings.js | 7 +++ public/javascripts/beathaven/vkontakte.js | 11 ++-- public/settings.html | 1 + public/stylesheets/misc.css | 13 +++++ 11 files changed, 100 insertions(+), 33 deletions(-) create mode 100644 public/images/icns/settings.png create mode 100644 public/javascripts/beathaven/settings.js create mode 100644 public/settings.html diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 69e4d43..da23ae5 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,38 +1,50 @@ require 'digest' class UserController < ApplicationController - @@secret_key + def auth - # Defining secret key dependent on hostname - @@secret_key = request.host == 'beathaven.org' ? 'sdgwSbl3nNE4ZxafuPrp' : 's5zyjb693z6uV4rbhEyc' @res = {} + check = check_auth(params) - 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' - user = User.find_by_vkid(params[:mid]) - if user.nil? - user = User.new - user.vkid = params[:mid] - user.save - end - if user.name.nil? and not params[:name].nil? - user.name = params[:name] - user.save - end - @res[:id] = user.id - @res[:username] = user.name - else - @res[:status] = 'bad signature' + if check == true + @res[:status] = 'hello' + user = User.find_by_vkid(params[:mid]) + if user.nil? + user = User.new + user.vkid = params[:mid] + user.save end + @res[:id] = user.id + @res[:username] = user.name + elsif check == false + @res[:status] = 'bad signature' else @res[:status] = 'bad params' end render :json => @res end + + def update + + end + + private + + def check_auth params + secret_key = request.host == 'beathaven.org' ? 'sdgwSbl3nNE4ZxafuPrp' : 's5zyjb693z6uV4rbhEyc' + 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] + return true + else + return false + end + else + return 'bad params' + end + end + end diff --git a/public/images/icns/settings.png b/public/images/icns/settings.png new file mode 100644 index 0000000000000000000000000000000000000000..cd2864f2d8ff16d9d104ddead38bad1a842469a3 GIT binary patch literal 3137 zcmV-H48HS;P)4Tx0C)kNmUmPX*B8g%%xo{TU6vwc>AklFq%OTkl_mFQv@x1^BM1TV}0C2duqR=S6Xn?LjUp6xrb&~O43j*Nv zEr418u3H3zGns$s|L;SQD-ufpfWpxLJ03rmi*g~#S@{x?OrJ!Vo{}kJ7$ajbnjp%m zGEV!%=70KpVow?KvV}a4moSaFCQKV= zXBIPnpP$8-NG!rR+)R#`$7JVZi#Wn10DSspSrkx`)s~4C+0n+?(b2-z5-tDd^^cpM zz5W?wz5V3zGUCskL5!X++LzcbT23thtSPiMTfS&1I{|204}j|3FPi>70OSh+Xzlyz zdl<5LNtZ}OE>>3g`T3RtKG#xK(9i3CI(+v0d-&=+OWAp!Ysd8Ar*foO5~i%E+?=c& zshF87;&Ay)i~kOm zCIB-Z!^JGdti+UJsxgN!t(Y#%b<8kk67vyD#cE*9urAm@Y#cTXn~yERR$}Y1E!Yd# zo7hq8Ya9;8z!~A3Z~?e@Tn26#t`xT$*Ni)h>&K1Yrto;Y8r}@=h7ZGY@Dh9xekcA2 z{tSKqKZ<`tAQQ9+wgf*y0zpVvOQ<9qCY&Y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