Skip to content

Create your own statergy

Scott Robertson edited this page Jan 17, 2021 · 1 revision

If you have a custom auth system, you can simply create your own Auth Strategy, and Tokenable will use it.

All you need to do is add something similar to your User model.

# The params are passed directly from a controller, so you can do anything with
# them that you normally would within a controller.
def self.from_tokenable_params(params)
  user = User.find_by(something: params[:something])
  return nil unless user.present?

  return nil unless user.password_valid?(params[:password])
  user
end

Clone this wiki locally