Bind vkontakte authentication to your authlogic project.
Install
script/plugin install authlogic_vkontakte
Setup
Run rake task to init resources (javascripts and other)
rake vkontakte:init
Edit vkontakte.yml file in your project directory
vk_app_id: <YOUR_APP_ID>
vk_app_password: <YOUR_PASSWORD>
Create migration like this one:
class AddVkontakteIdToUser < ActiveRecord::Migration
def self.up
add_column :users, :vk_id, :string
end
def self.down
remove_column :users, :vk_id
end
end
Add “vontakte_authentication” to your User model
class User < ActiveRecord::Base
vkontakte_authentication
end
And a little requirement now - jQuery (see vkontakte.js) for posting to “create” action of UserSessionController. But you can use Ajax.Request if you prefer Prototype. And so, TODO is to create version independent of the javascript framework.
Usage
To include javascript file in layout:
<%= vkontakte_javascript_include_tag %>
Creating “vk_api_transport” ‘div’ and initializing OpenAPI:
<%= vkontakte_init_tag %>
To add Vkontakte button to your page, simply write this in view:
<%= vk_login_button %>
or, in haml
= vk_login_button
In your controller (UserSession):
def create
@user_session = UserSession.new(params[:status] ? cookies : params[:user_session])
if @user_session.save
..
…and you’re in Vkontakte!