lib/volt/volt/users.rb
def user_id
      user_id_signature = self.user_id_signature

      if user_id_signature.nil?
        return nil
      else
        index = user_id_signature.index(':')
        user_id = user_id_signature[0...index]

        if RUBY_PLATFORM != 'opal'
          hash = user_id_signature[(index+1)..-1]

          # Make sure the user hash matches
          if BCrypt::Password.new(hash) != "#{Volt.config.app_secret}::#{user_id}"
            # user id has been tampered with, reject
            raise "user id or hash has been tampered with"
          end

        end

        return user_id
      end
    end
# Get the user_id from the cookie
Get the user_id from the cookie
Get the user_id from the cookie
def user_id
      user_id_signature = self.user_id_signature
      if user_id_signature.nil?
        return nil
      else
        index = user_id_signature.index(':')
        user_id = user_id_signature[0...index]
        if RUBY_PLATFORM != 'opal'
          hash = user_id_signature[(index+1)..-1]
          if BCrypt::Password.new(hash) != "#{Volt.config.app_secret}::#{user_id}"
            raise "user id or hash has been tampered with"
          end
        end
        return user_id
      end
    end
def user_id user_id_signature = self . user_id_signature if user_id_signature . nil? return nil else index = user_id_signature . index ( ':' ) user_id = user_id_signature [ 0 ... index ] if RUBY_PLATFORM != 'opal' hash = user_id_signature [ ( index + 1 ) .. - 1 ] if BCrypt :: Password . new ( hash ) != "#{Volt.config.app_secret}::#{user_id}" raise "user id or hash has been tampered with" end end return user_id end end
Get the user_id from the cookie
Get the user_id from the cookie
# Make sure the user hash matches # user id has been tampered with, reject