https://github.com/solidusio/solidus_auth_devise
🔑 Devise authentication for your Solidus store.
https://github.com/solidusio/solidus_auth_devise
ecommerce ecommerce-platform hacktoberfest solidus solidus-extensions
Last synced: 12 months ago
JSON representation
🔑 Devise authentication for your Solidus store.
- Host: GitHub
- URL: https://github.com/solidusio/solidus_auth_devise
- Owner: solidusio
- License: bsd-3-clause
- Created: 2015-05-19T21:20:39.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2025-01-08T06:30:30.000Z (over 1 year ago)
- Last Synced: 2025-05-13T09:08:43.800Z (12 months ago)
- Topics: ecommerce, ecommerce-platform, hacktoberfest, solidus, solidus-extensions
- Language: Ruby
- Homepage: http://solidus.io
- Size: 1.1 MB
- Stars: 55
- Watchers: 14
- Forks: 122
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Solidus Auth Devise
[](https://circleci.com/gh/solidusio/solidus_auth_devise)
[](https://codecov.io/gh/solidusio/solidus_auth_devise)
Provides authentication services for Solidus, using the Devise gem.
## Usage
### Installation
Add solidus_auth_devise to your Gemfile:
```ruby
gem 'solidus_auth_devise'
```
Then, run `bundle install`.
After that's done, you can install and run the necessary migrations, then seed the database:
```shell
bundle exec rake solidus_auth:install:migrations
bundle exec rake db:migrate
bundle exec rake db:seed
```
#### Default Username/Password
As part of running the above installation steps, you will be asked to set an admin email/password combination. The default values are `admin@example.com` and `test123`, respectively.
#### 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`):
```ruby
Spree::Auth::Config[:confirmable] = true
```
* Add a Devise initializer to your Rails project (typically `config/initializers/devise.rb`):
```ruby
Devise.setup do |config|
# Required so users don't lose their carts when they need to confirm.
config.allow_unconfirmed_access_for = 1.days
# Add any other devise configurations here, as they will override the defaults provided by solidus_auth_devise.
end
```
### Using in an existing application
If you are installing Solidus inside of a host application in which you want your own permission setup, you can do this using the `register_ability` method.
First create your own CanCan Ability class following the CanCan documentation.
For example: `app/models/super_abilities.rb`
```ruby
class SuperAbilities
include CanCan::Ability
def initialize user
if user.is? "Superman"
can :stop, Bullet
end
end
end
```
Then register your class in your spree initializer: config/initializers/spree.rb
```ruby
Spree::Ability.register_ability(SuperAbilities)
```
Inside of your host application you can then use CanCan like you normally would.
```erb
<% if can? :stop Bullet %>
...
<% end %>
```
## Development
### Testing the extension
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
`bin/rake extension:test_app`.
```shell
bin/rake
```
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
```shell
bundle exec rubocop
```
When testing your application's integration with this extension you may use its factories.
Simply add this require statement to your `spec/spec_helper.rb`:
```ruby
require 'solidus_auth_devise/testing_support/factories'
```
Or, if you are using `FactoryBot.definition_file_paths`, you can load Solidus core
factories along with this extension's factories using this statement:
```ruby
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusAuthDevise::Engine)
```
### Running the sandbox
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
`sandbox/bin/rails`.
Here's an example:
```
$ bin/rails server
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
* Listening on tcp://127.0.0.1:3000
Use Ctrl-C to stop
```
### Updating the changelog
Before and after releases the changelog should be updated to reflect the up-to-date status of
the project:
```shell
bin/rake changelog
git add CHANGELOG.md
git commit -m "Update the changelog"
```
### Releasing new versions
Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
## License
Copyright (c) 2022 Solidus Team, released under the New BSD License.