Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
rails:
- rails_8.1
- rails_8.0
- rails_7.2
- rails_7.1
exclude:
- ruby: '3.1'
rails: 'rails_8.0'
Expand Down
17 changes: 0 additions & 17 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
# frozen_string_literal: true

appraise 'rails_7.1' do
gem 'rails', '~> 7.1.0'
gem 'sqlite3', '~> 1.5.0'

# Fix:
# warning: logger was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.5.0.
# Add logger to your Gemfile or gemspec.
install_if '-> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") }' do
gem 'logger'
end
end

appraise 'rails_7.2' do
gem 'rails', '~> 7.2.0'
gem 'sqlite3', '~> 1.5.0'
end

appraise 'rails_8.0' do
gem 'rails', '~> 8.0.0'
end
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Unreleased
Maintenance
- Disable tests for Rails 7.1 (EOL on 10/2025) and 7.2 (EOL on 8/9/2026)

README
- Switch README to feature native CSS import for Propshaft;
- Add Getting Started section with sample link to OTP Token page;

## v2.0.0

Bug fixes:
Expand Down
45 changes: 32 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,43 @@ Run the following generator to add the necessary configuration options to Devise

rails g devise_otp:install

After you've created your Devise user models (which is usually done with a `rails g devise MODEL`), set up your Devise OTP additions:
## Getting Started

Create your Devise user model if you have not done so

rails g devise MODEL

Add Devise OTP to the model

rails g devise_otp MODEL

Don't forget to migrate:
Add a link to the OTP Token settings to your navigation menu (or equivalent) for the user model

rake db:migrate
<%= link_to "OTP Token", user_otp_token_path %>

### Default CSS
NOTE: replace "user" with the lowercase name of the model (same as the main devise gem)

To use the default CSS for devise-otp, just require the devise-otp.css file as usual in your application.css file (or equivalent):
## Default CSS

*= require devise-otp
To use the default CSS for devise-otp, just import the devise-otp.css file into your application.css file (or equivalent):

It might be even easier to just copy the styles to your project.
@import url("devise-otp.css");

### Custom views
NOTE: You can also copy/paste the styles from [devise-otp.css](https://github.com/wmlele/devise-otp/blob/master/app/assets/stylesheets/devise-otp.css) into your stylesheet.

## Custom views

If you want to customise your views, you can use the following generator to eject the default view files:

rails g devise_otp:views

By default, the files live within the Devise namespace (`app/views/devise`, but if you want to move them or want to match the Devise configuration, set `config.otp_controller_path` in your initializers.

### I18n
## I18n

The install generator also installs an english copy of a Devise OTP i18n file. This can be modified (or used to create other language versions) and is located at: _config/locales/devise.otp.en.yml_

### QR codes
## QR codes

Devise OTP generates QR Codes directly as SVG's via the [rqrcode](https://github.com/whomwah/rqrcode), so there are no JavaScript (or Sprockets) dependencies.

Expand Down Expand Up @@ -110,10 +118,21 @@ To run the devise-otp dummy application in the development environment:
- Run the rails console or server (e.g. "rails c")

To run the tests for devise-otp against your current Ruby/Rails configuration:
- Navigate to the dummy app directory ("cd test/dummy")
- Create and migrate the database for the test environment ("RAILS\_ENV=test rails db:drop db:create db:migrate")
- Navigate to the dummy app directory

cd test/dummy

- Create and migrate the database for the test environment

RAILS\_ENV=test rails db:drop
RAILS\_ENV=test rails db:create
RAILS\_ENV=test rails db:migrate

- Return to the root directory of devise-otp
- Run "rake test"

- Execute the tests

rake test

To check Ruby syntax and formatting:
- Rubocop: "./bin/rubocop"
Expand Down
25 changes: 0 additions & 25 deletions gemfiles/rails_7.1.gemfile

This file was deleted.

21 changes: 0 additions & 21 deletions gemfiles/rails_7.2.gemfile

This file was deleted.

16 changes: 15 additions & 1 deletion test/dummy/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require devise-otp
*= require_self
*= require_tree .
*/

@import url("devise-otp.css");

nav {
ul {
float: right;
margin: 0;
display: flex;
}
li {
list-style: none;
padding: 0.25rem 0.5rem;;
margin: 0;
}
}
22 changes: 15 additions & 7 deletions test/dummy/app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<nav>
<div style="float: right;">
<ul style="float: right;">
<li><%= link_to "Home", root_path %></li>
<% if current_user.present? %>
<%= button_to "Sign Out", destroy_user_session_path, method: :delete, data: { turbo_method: :delete } %>
<li><%= link_to "Posts", posts_path %></li>
<li><%= link_to "OTP Token", user_otp_token_path %></li>
<li><%= button_to "Sign Out", destroy_user_session_path, method: :delete, data: { turbo_method: :delete } %></li>
<% elsif current_admin.present? %>
<%= button_to "Sign Out", destroy_admin_session_path, method: :delete, data: { turbo_method: :delete } %>
<li><%= link_to "Posts", admin_posts_path %></li>
<li><%= link_to "OTP Token", admin_otp_token_path %></li>
<li><%= button_to "Sign Out", destroy_admin_session_path, method: :delete, data: { turbo_method: :delete } %></li>
<% elsif current_lockable_user.present? %>
<%= button_to "Sign Out", destroy_lockable_user_session_path, method: :delete, data: { turbo_method: :delete } %>
<li><%= link_to "OTP Token", lockable_user_otp_token_path %></li>
<li><%= button_to "Sign Out", destroy_lockable_user_session_path, method: :delete, data: { turbo_method: :delete } %></li>
<% elsif current_non_otp_user.present? %>
<%= button_to "Sign Out", destroy_non_otp_user_session_path, method: :delete, data: { turbo_method: :delete } %>
<li><%= link_to "Posts", admin_posts_path %></li>
<li><%= button_to "Sign Out", destroy_non_otp_user_session_path, method: :delete, data: { turbo_method: :delete } %></li>
<% elsif current_rememberable_user.present? %>
<%= button_to "Sign Out", destroy_rememberable_user_session_path, method: :delete, data: { turbo_method: :delete } %>
<li><%= link_to "OTP Token", rememberable_user_otp_token_path %></li>
<li><%= button_to "Sign Out", destroy_rememberable_user_session_path, method: :delete, data: { turbo_method: :delete } %></li>
<% end %>
</div>
</ul >
</nav>
Loading
Loading