Sha256: c135b2f03bd6f9da86d7278391deb839719e350f621b381a6a6a9aee64e8cc5d

Contents?: true

Size: 1.11 KB

Versions: 27

Compression:

Stored size: 1.11 KB

Contents

module Maestrano
  module SSO
    module User
      def find_for_maestrano_auth(auth)
        # E.g with Rails
        # where(auth.slice(:provider, :uid)).first_or_create do |user|
        #   user.provider = auth[:provider]
        #   user.uid = auth[:uid]
        #   user.email = auth[:info][:email]
        #   user.name = auth[:info][:first_name]
        #   user.surname = auth[:info][:last_name]
        #   user.country = auth[:info][:country]
        #   user.company = auth[:info][:company_name]
        # end
        raise NoMethodError, "You need to override find_for_maestrano_auth in your #{self.class.name} model"
      end
      
      # Check whether the user is a maestrano one
      def maestrano?
        if self.respond_to?(:provider)
          return self.provider.to_s == 'maestrano'
        else
          raise NoMethodError, "You need to override maestrano? in your #{self.class.name} model"
        end
      end
      
      # Check whether the SSO session is still valid
      # or not
      def maestrano_session_valid?(session)
        Maestrano::SSO::Session.new(session).valid?
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
maestrano-1.0.0.pre.RC5 lib/maestrano/sso/user.rb
maestrano-1.0.0.pre.RC4 lib/maestrano/sso/user.rb
maestrano-1.0.0.pre.RC3 lib/maestrano/sso/user.rb
maestrano-1.0.0.pre.RC2 lib/maestrano/sso/user.rb
maestrano-1.0.0.pre.RC1 lib/maestrano/sso/user.rb
maestrano-0.12.5 lib/maestrano/sso/user.rb
maestrano-0.12.4 lib/maestrano/sso/user.rb
maestrano-0.12.3 lib/maestrano/sso/user.rb
maestrano-0.12.2 lib/maestrano/sso/user.rb
maestrano-0.12.1 lib/maestrano/sso/user.rb
maestrano-0.12.0 lib/maestrano/sso/user.rb
maestrano-0.11.0 lib/maestrano/sso/user.rb
maestrano-0.10.0 lib/maestrano/sso/user.rb
maestrano-0.9.2 lib/maestrano/sso/user.rb
maestrano-0.9.1 lib/maestrano/sso/user.rb
maestrano-0.9.0 lib/maestrano/sso/user.rb
maestrano-ruby-test-0.8.3 lib/maestrano/sso/user.rb
maestrano-0.8.2 lib/maestrano/sso/user.rb
maestrano-0.8.1 lib/maestrano/sso/user.rb
maestrano-0.8.0 lib/maestrano/sso/user.rb