• Stars
    star
    135
  • Rank 260,630 (Top 6 %)
  • Language
    Ruby
  • License
    BSD 3-Clause "New...
  • Created almost 12 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Provides authentication (user accounts, login & signup) for @spree by using Devise

Spree Auth (Devise)

CircleCI

Provides authentication services for Spree, using the Devise gem.

Developed by

Vendo

All-in-one platform for all your Marketplace and B2B eCommerce needs. Start your 30-day free trial

Installation

  1. Add this extension to your Gemfile with this line:
gem 'spree_auth_devise'

if you run into any version-mismatch problems please run bundle update

  1. Install the gem using Bundler:
bundle install
  1. Copy & run migrations
bundle exec rails g spree:auth:install

Upgrading from Spree 3.0 to 3.1

If you're upgrading from 3.0 to 3.1 you need to rerun the installer to copy new asset files (javascripts)

bundle exec rails g spree:auth:install

Configuration

Confirmable

To enable Devise's Confirmable module, which will send the user an email with a link to confirm their account, you must do the following:

  • Add this line to an initializer in your Rails project (typically config/initializers/spree.rb):
Spree::Auth::Config[:confirmable] = true
  • Add a Devise initializer to your Rails project (typically config/initializers/devise.rb):
Devise.setup do |config|
  # Required so users don't lose their carts when they need to confirm.
  config.allow_unconfirmed_access_for = 1.days

  # Fixes the bug where Confirmation errors result in a broken page.
  config.router_name = :spree

  # Add any other devise configurations here, as they will override the defaults provided by spree_auth_devise.
end

Sign out after password change

To disable signout after password change you must add this line to an initializer in your Rails project (typically config/initializers/spree.rb):

Spree::Auth::Config[:signout_after_password_change] = false

Using in an existing Rails application

If you are installing Spree inside of a host application in which you want your own permission setup, you can do this using spree_auth_devise's register_ability method.

First create your own CanCan Ability class following the CanCan documentation.

For example: app/models/your_ability_class.rb

class YourAbilityClass
  include CanCan::Ability

  def initialize user
    # direct permissions
     can :create, SomeRailsObject

     # or permissions by group
     if spree_user.has_spree_role? "admin"
       can :create, SomeRailsAdminObject
     end
   end
end

Then register your class in your spree initializer: config/initializers/spree.rb

Spree::Ability.register_ability(YourAbilityClass)

Inside of your host application you can then use CanCan like you normally would.

<% if can? :show, SomeRailsObject %>

<% end %>

Adding Permissions to Gems

This methodology can also be used by gems that extend spree and want/need to add permissions.

Ruby 2.5 issues

If you encounter issues when using Ruby 2.5, please run:

bundle update devise

Creating the default Admin user

If you didn't created the Admin user from the installer you can run this rake task:

bundle exec rake spree_auth:admin:create

Testing

You need to do a quick one-time creation of a test application and then you can use it to run the tests.

bundle exec rake test_app

Then run the rspec tests.

bundle exec rspec

More Repositories

1

spree

Open Source eCommerce platform for global brands. An alternative to Shopify, Salesforce Commerce Cloud, Adobe Commerce etc. 🛒
Ruby
12,589
star
2

spree_starter

@spree application starter template
Ruby
348
star
3

spree_gateway

Huge collection of payment gateways for @spree. Stripe, Braintree, Apple Pay, Authorize.net and many others!
Ruby
216
star
4

spree-api-v2-js-sdk

Spree Storefront API JavaScript / TypeScript SDK
TypeScript
105
star
5

spree-guides

Official Spree Documentation
CSS
88
star
6

spree_wombat

Connect your Spree Commerce storefront to Wombat
Ruby
31
star
7

spree_backend

Spree Admin Dashboard
Ruby
26
star
8

spree_gift_cards

Ruby
18
star
9

spree_rails_frontend

Spree Rails storefront
Ruby
13
star
10

amazon_endpoint

Ruby
12
star
11

spree_share

Share products with others via social networking (Facebook,Twitter, etc.)
Ruby
9
star
12

spree-dev-docs

Spree Commerce Developer Documentation - https://dev-docs.spreecommerce.org
8
star
13

deployment_service_puppet

Ruby
8
star
14

endpoint_base

Ruby
7
star
15

abandoned_carts_endpoint

Ruby
6
star
16

spreebot

Automated bot designed for helping out the Spree community
Ruby
6
star
17

spree_dev_tools

Spree Developer Tools
Ruby
5
star
18

api.spreecommerce.com

JavaScript
4
star
19

deployment_service_website

Deployment Service web interface extracted from spreecommerce.com
Ruby
4
star
20

hub_gem

Helper gem to help communication between a Spree Commerce storefront and hub
Ruby
3
star
21

google_analytics_endpoint

Ruby
3
star
22

spree_pro_connector

Ruby
2
star
23

desk_endpoint

Spree Commerce hub integration for Desk.com
Ruby
2
star
24

spree_hub_connector

Connects your storefront to the SpreeCommerce hub.
CSS
2
star
25

integration_tutorials

Ruby
2
star
26

spree_extension

Common tools and helpers for Spree Extensions developers
Ruby
2
star
27

spree-user-docs

1
star
28

spree_cli_data

1
star
29

smtp_endpoint

Ruby
1
star
30

spree-guides-gatsby

Old Spree Guides, please visit https://dev-docs.spreecommerce.org instead
JavaScript
1
star
31

spree_cli

TypeScript
1
star