Sha256: e2bf8b2b4df0c44bb70991700dc23f48330140722bd82dc1fc8de6856ad7f063

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

# Responsibility - have one API for all frameworks
# Wrap on Rack frameworks (Sinatra, Rails ...)
module Vxod
  class App
    def initialize(rack_app)
      @rack_app = rack_app
    end

    attr_reader :rack_app

    def redirect(url)
      rack_app.redirect(url)
    end

    def request_path
      rack_app.request.path
    end

    def params
      rack_app.params
    end

    def session
      rack_app.session
    end

    def omniauth_hash
      rack_app.env['omniauth.auth']
    end

    def authentify(auth_key)
      rack_app.response.set_cookie('vxod.auth', 
        value: auth_key,
        path: '/',
        expires: Time.new(DateTime.now.year + 10, 1, 1),
        httponly: true,
      )      
    end

    def authentify_for_fill_user_data(auth_key)
      rack_app.response.set_cookie('vxod.auth_fill_user_data', 
        value: auth_key,
        path: Vxod.config.fill_user_data_path,
        httponly: true,
      )      
    end

    def auth_key_for_fill_user_data
      rack_app.request.cookies['vxod.auth_fill_user_data']
    end

    def auth_key
      rack_app.request.cookies['vxod.auth']
    end

    def detele_auth_key
      rack_app.response.set_cookie('vxod.auth', nil)
    end

    def after_login_path
      BackPath.new(rack_app).get
    end

    def redirect_to_after_login
      redirect(after_login_path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vxod-0.0.2 lib/vxod/app.rb