nthj / gone-in-60-milliseconds

Further resources and some code around a talk originally given at Austin on Rails on May 24th, 2016.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slides

PDF here :)

Further Resources

Alternatives

Gotchas

Deployment

Performance

Examples of Authentication

module ApplicationCable
  class Connection < ActionCable::Connection::Base
    identified_by :current_user

    def connect
      self.current_user = find_verified_user
    end

    def session
      cookies.encrypted[Rails.application.config.session_options[:key]]
    end

    def ability
      @ability ||= Ability.new(current_user)
    end

    protected
    def find_verified_user
      User.find_by(id: session["user_id"])
    end
  end
end

and

module ApplicationCable
  class Channel < ActionCable::Channel::Base
    delegate :session, :ability, to: :connection
    # dont allow the clients to call those methods
    protected :session, :ability
  end
end

Questions

Hey, I'm @thenthj on Twitter.

Acknowledgements

Thanks to @austinonrails for having me on May 24th, 2016. :)

About

Further resources and some code around a talk originally given at Austin on Rails on May 24th, 2016.


Languages

Language:Ruby 77.6%Language:HTML 14.4%Language:CSS 3.2%Language:JavaScript 3.1%Language:CoffeeScript 1.6%