Sha256: 645ebcd802c3645601ec04be46a104850f10071b5b76fb7cd29cc9dc3b4e50f1

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

class DoubanController < ApplicationController
  def new
    douban = Douban.new
    douban.callback = douban_callback_url
    authorize_url = douban.authorize_url
    
    respond_to do |wants|
      session[:back]   = request.env['HTTP_REFERER'] unless request.env['HTTP_REFERER'].blank?
      session[:douban] = douban.dump
      wants.html {redirect_to authorize_url}
    end
  end
  
  def callback
    if session[:douban]
      douban = Douban.load(session[:douban])
      douban.authorize
      session[:douban] = douban.dump
    end
    
    redirect_to(session[:back] || '/')
    session[:back] = nil
  end
  
  def destroy
    return unless douban_authorized?
    session[:douban] = nil
    douban.destroy
    redirect_to '/'
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
douban-rails2.3-0.6.4 generators/douban/templates/douban_controller.rb
douban-0.1.0 lib/generators/douban/templates/douban_controller.rb