Class: OmniAuth::Strategies::Vkontakte
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::Vkontakte
- Includes:
- ViewHelper::PageHelper, OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/vkontakte.rb,
lib/omniauth/strategies/vkontakte/view_helper.rb
Defined Under Namespace
Classes: ViewHelper
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
Instance Method Summary collapse
- #auth_hash ⇒ Object
- #callback_phase ⇒ Object
-
#initialize(app, app_id, app_key, params = {:permissions => '1'}) ⇒ Vkontakte
constructor
Про права приложения можно узнать здесь: vkontakte.ru/developers.php?o=-1&p=%D0%9F%D1%80%D0%B0%D0%B2%D0%B0+%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B9.
- #request_phase ⇒ Object
Methods included from ViewHelper::PageHelper
#vkontakte_footer, #vkontakte_header, #vkontakte_login_button, #vkontakte_login_page
Constructor Details
#initialize(app, app_id, app_key, params = {:permissions => '1'}) ⇒ Vkontakte
Про права приложения можно узнать здесь: vkontakte.ru/developers.php?o=-1&p=%D0%9F%D1%80%D0%B0%D0%B2%D0%B0+%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B9
19 20 21 22 23 24 |
# File 'lib/omniauth/strategies/vkontakte.rb', line 19 def initialize(app, app_id, app_key, params = {:permissions => '1'}) OmniAuth.config.vkontakte_app_id = app_id OmniAuth.config.vkontakte_app_key = app_key OmniAuth.config.vkontakte_params = params super(app, :vkontakte) end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
26 27 28 |
# File 'lib/omniauth/strategies/vkontakte.rb', line 26 def app_id @app_id end |
Instance Method Details
#auth_hash ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/omniauth/strategies/vkontakte.rb', line 43 def auth_hash OmniAuth::Utils.deep_merge(super(), { 'uid' => request[:uid], 'user_info' => { 'nickname' => request[:nickname], 'name' => "#{request[:first_name]} #{request[:last_name]}", 'first_name' => request[:first_name], 'last_name' => request[:last_name], 'image' => request[:photo], 'urls' => { 'Page' => 'http://vkontakte.ru/id' + request[:uid] } } }) end |
#callback_phase ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/omniauth/strategies/vkontakte.rb', line 32 def callback_phase = request.["vk_app_#{OmniAuth.config.vkontakte_app_id}"] return fail!(:invalid_credentials) unless args = .split("&") sig_index = args.index { |arg| arg =~ /^sig=/ } return fail!(:invalid_credentials) unless sig_index sig = args.delete_at(sig_index) return fail!(:invalid_credentials) unless Digest::MD5.new.hexdigest(args.sort.join('') + OmniAuth.config.vkontakte_app_key) == sig[4..-1] super end |
#request_phase ⇒ Object
28 29 30 |
# File 'lib/omniauth/strategies/vkontakte.rb', line 28 def request_phase Rack::Response.new(vkontakte_login_page).finish end |