Giter Site home page Giter Site logo

Comments (3)

stefanvermaas avatar stefanvermaas commented on June 22, 2024 1

I'm not using it anymore indeed, but thanks for providing the answer to my question @skylarmacdonald! At least it will help the community to find the answer :)!

from authie.

stefanvermaas avatar stefanvermaas commented on June 22, 2024

Small update;

Whenever I tried to implement the current logic from the Authie::RackController myself inside the class, it all seems to work. So, it might be an autoload thing.

class UserKindConstraint
  class RackController
    def initialize(request)
      @env = request.env
      @request = request
    end

    def auth_session
      @auth_session ||= Authie::Session.get_session(self)
    end

    def current_user
      auth_session.user if auth_session.is_a?(Authie::Session)
    end
  end

  def initialize(user_type)
    @user_type = user_type
  end

  # Only returns true if there is a session with a user_id in it, if the user
  # can be found, and that user has the proper kind. False in every other case.
  def matches?(request)
    controller = RackController.new(request)
    current_user = controller.current_user
    current_user && current_user.send("#{@user_type}?".to_sym)
  end
end

from authie.

skylarmacdonald avatar skylarmacdonald commented on June 22, 2024

This is two years later, so I don't know if you're still having this problem (or even still using Authie), but I found that adding this:

require 'authie/rack_controller'

at the top of my constraint file did the trick. It doesn't look like the gem loads that class by default.

from authie.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.