Sha256: 50bce2ee6a9abc04934e33f119197aea76d25ed5bd1e8a7dbeeff3ce11d15161

Contents?: true

Size: 1.36 KB

Versions: 12

Compression:

Stored size: 1.36 KB

Contents

class AuthorizationsController < ApplicationController

  def index
    @title = "Authorizations"
    authorize! :read, Authorization
    @authorizations = Authorization.all
  end

  def new
    @title = "New Authorization"
    authorize! :create, Authorization
    @authorization = Authorization.new
  end

  def create
    @authorization = Authorization.new(params[:authorization])
    authorize! :create, @authorization

    if @authorization.save
      redirect_to authorizations_path
    else
      render action: :new
    end
  end

  def edit
    @title = "Edit Authorization"
    @authorization = Authorization.find params[:id]
    authorize! :update, Authorization
  end

  def update
    @authorization = Authorization.find params[:id]
    authorize! :update, Authorization

    if @authorization.update_attributes(params[:authorization])
      redirect_to authorizations_path
    else
      render action: :new
    end
  end

  def grant
    @authorization = Authorization.find(params[:id])
    if @authorization.granted?
      redirect_to authorizations_url, notice: "Already Granted"
    else
      puts "\e[96;4m#{@authorization.authorize_url}\e[0m"
      redirect_to @authorization.authorize_url
    end
  end

  def oauth2_callback
    authorization = Authorization.set_access_token! params
    redirect_to authorization_granted_url(authorization)
  end

  def granted
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
houston-core-0.8.4 app/controllers/authorizations_controller.rb
houston-core-0.8.3 app/controllers/authorizations_controller.rb
houston-core-0.8.2 app/controllers/authorizations_controller.rb
houston-core-0.8.1 app/controllers/authorizations_controller.rb
houston-core-0.8.0 app/controllers/authorizations_controller.rb
houston-core-0.8.0.pre2 app/controllers/authorizations_controller.rb
houston-core-0.8.0.pre app/controllers/authorizations_controller.rb
houston-core-0.7.0 app/controllers/authorizations_controller.rb
houston-core-0.7.0.beta4 app/controllers/authorizations_controller.rb
houston-core-0.7.0.beta3 app/controllers/authorizations_controller.rb
houston-core-0.7.0.beta2 app/controllers/authorizations_controller.rb
houston-core-0.7.0.beta app/controllers/authorizations_controller.rb