Authentication
Learn how to use a custom authentication setup with Spree
This guide covers using a custom authentication setup with Spree, such as one provided by your own application. This is ideal in situations where you want to handle the sign-in or sign-up flow of your application uniquely, outside the realms of what would be possible with Spree or you have an existing authentication with user accounts present.
This guide assumes that you have a pre-existing model inside your application that represents the users of your application already. This model could be provided by gems such as Devise. This guide also assumes that the application that this User
model exists in is already a Spree application.
This model does not need to be called User
, but for the purposes of this guide the model we will be referring to will be called User
. If your model is called something else, do some mental substitution wherever you see User
.
To use your own authentication system with Spree, please follow these steps:
Admin Panel authentication
By default Spree uses the same model for the admin panel as the storefront. However you can customize it to use a different model.
To do this, you need to add the following code to your config/initializers/spree.rb
file:
This will tell Spree to use the AdminUser
model for the admin panel. You will need to create this model in your application and ensure that it includes the necessary Spree fields.
Was this page helpful?