Home > freeberry_auth

freeberry_auth

Freeberry_auth is a project mainly written in Ruby, based on the MIT license.

Social authorization system via Loginza or RPX

= FreeberryAuth

== Install

In Gemfile:

gem 'freeberry_auth', :git => 'git://github.com/galetahub/freeberry_auth.git'

Generate migration:

rails g freeberry_auth:install rake db:migrate

== Logger

Use rails default logger:

FreeberryAuth.logger = Rails.logger

or

require 'logger'

logfile = File.open(Rails.root.join('log', 'freeberry_auth.log'), 'w') logfile.sync = true

FreeberryAuth.logger = Logger.new(logfile)

== Example

Login via loginza

<%= loginza_button_tag("Login", auth_provider_url('loginza'), :class => "loginza") %>

Login via vkontakte

<%= link_to 'Login', auth_provider_url('vkontakte') %>

Logout

<%= link_to "Exit", "/auth/logout" if account_signed_in? %>

== Controller helpers

current_account # return nil or FreeberryAuth::Account object

account_signed_in? # return true or false

current_client # return current_user or current_account

client_signed_in? # check user_signed_in? or account_signed_in?

You must describe helper method "extract_path_proc". This method must return path to redirect with, after success authorization. By default it return '/'.

<%= loginza_button_tag("Vote", auth_accounts_url(:kind => 'post', :id => @post.id), :class => "loginza") %>

FreeberryAuth.extract_path_proc = Proc.new do |params| klass = (params[:kind] || '').to_s.downcase.strip record_id = (params[:id] || 0).to_i

case klass
  when 'post' then "/posts/#{record_id}"
  else '/'
end

end

== I18n

en: flash: freeberry_auth: accounts: create: success: "Signed in successfully." failure: "You need to sign in or sign up before continuing." destroy: success: "Signed out successfully."

Copyright (c) 2011 Aimbulance, released under the MIT license

Previous:jQuery-Slideshow