action_auth 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c85ae94ede51ba040295cfca1ec2f6a46f412642bc3e3a3ada8fd102bec41ab
4
- data.tar.gz: bf218c5419f6cf1a7f8eb5b70f0cbb58f9af1710be3222ee0a333075af32e5c5
3
+ metadata.gz: 2199e638d124811034db20d5d3cd6f0b23d56acf260d42e18f9559bf54405295
4
+ data.tar.gz: ab312a35ead67087ab41cfb30f54a42696521924fb1e695870e87632742497d6
5
5
  SHA512:
6
- metadata.gz: e09cef2c34868ff6e6bd0e4d81f6e5fa577d91c0b38d957f09b36aa48a2cf4a183b2ff0bc400c321eb03829aef23c3976188d108b3e9a2f6f887e2e3a86f7043
7
- data.tar.gz: c3cce12a87a5bfdc1b785ed01cb2cbed07325f9e65150e4fe5e5a7b86c6f6a52f5357aad6d51510a9e87a92f389441b268462917f0ea619980d6d130bd681ad6
6
+ metadata.gz: 53f6e3b604bc0037a751269cd16975e243e84ebd1018419764c88a2b60a8309455736b2b7a2ec1e6b29cb2970e4e0020348756fed9658400f32d2d3a2f3b179a
7
+ data.tar.gz: 0ccad04b7a3e4ccbb50e80149b40d452364089600a2a5462ea2392ece13151f8903f65c491d8bd3dc5507ae6fac3ac6430ae18b0b0ac247acb434f898a3c3055
data/README.md CHANGED
@@ -98,12 +98,13 @@ settings.
98
98
 
99
99
  ```ruby
100
100
  ActionAuth.configure do |config|
101
+ config.allow_user_deletion = true
102
+ config.default_from_email = "from@example.com"
103
+ config.magic_link_enabled = true
104
+ config.verify_email_on_sign_in = true
101
105
  config.webauthn_enabled = true
102
106
  config.webauthn_origin = "http://localhost:3000" # or "https://example.com"
103
107
  config.webauthn_rp_name = Rails.application.class.to_s.deconstantize
104
- config.verify_email_on_sign_in = true
105
- config.magic_link_enabled = true
106
- config.default_from_email = "from@example.com"
107
108
  end
108
109
  ```
109
110
 
@@ -129,7 +130,7 @@ These are the planned features for ActionAuth. The ones that are checked off are
129
130
 
130
131
  ⏳ - OAuth with Google, Facebook, Github, Twitter, etc.
131
132
 
132
- - Account Deletion
133
+ - Account Deletion
133
134
 
134
135
  ⏳ - Account Lockout
135
136
 
@@ -213,6 +214,29 @@ they can add a Passkey to their account. The Passkey could be an iCloud Keychain
213
214
  key like a Yubikey, or a mobile device. If enabled and configured, the user will be prompted to use
214
215
  their Passkey after they log in.
215
216
 
217
+ ## Magic Links
218
+
219
+ Magic Links are a way to authenticate a user without requiring a password. This is done by sending
220
+ an email to the user with a link that will log them in. This is a great way to allow users to log in
221
+ without having to remember a password. This is especially useful for users who may not have a password
222
+ manager or have a hard time remembering passwords.
223
+
224
+ ## Account Deletion
225
+
226
+ Account deletion is a feature that is enabled by default. When a user deletes their account, the account
227
+ is marked as deleted and the user is logged out. The user will no longer be able to log in with their
228
+ email and password. The user will need to create a new account if they wish to continue using the application.
229
+
230
+ Here's an example of how you may want to add a delete account button to your application. Obviously, you
231
+ will want to style this to fit your application and have some kind of confirmation dialog.
232
+
233
+ ```
234
+ <p>
235
+ Unhappy with the service?
236
+ <%= button_to "Delete Account", action_auth.users_path, method: :delete %>
237
+ </p>
238
+ ```
239
+
216
240
  #### Configuration
217
241
 
218
242
  The migrations are already copied over to your application when you run
@@ -0,0 +1,10 @@
1
+ module ActionAuth
2
+ class UsersController < ApplicationController
3
+ before_action :authenticate_user!
4
+
5
+ def destroy
6
+ Current.user.destroy
7
+ redirect_to main_app.root_url, notice: "Your account has been deleted."
8
+ end
9
+ end
10
+ end
data/config/routes.rb CHANGED
@@ -3,13 +3,18 @@ ActionAuth::Engine.routes.draw do
3
3
  post "sign_in", to: "sessions#create"
4
4
  get "sign_up", to: "registrations#new"
5
5
  post "sign_up", to: "registrations#create"
6
- resources :sessions, only: [:index, :show, :destroy]
7
- resource :password, only: [:edit, :update]
6
+
8
7
  namespace :identity do
9
8
  resource :email, only: [:edit, :update]
10
9
  resource :email_verification, only: [:show, :create]
11
10
  resource :password_reset, only: [:new, :edit, :create, :update]
12
11
  end
12
+ resource :password, only: [:edit, :update]
13
+ resources :sessions, only: [:index, :show, :destroy]
14
+
15
+ if ActionAuth.configuration.allow_user_deletion?
16
+ resource :users, only: [:destroy]
17
+ end
13
18
 
14
19
  if ActionAuth.configuration.webauthn_enabled?
15
20
  resources :webauthn_credentials, only: [:new, :create, :destroy] do
@@ -1,29 +1,36 @@
1
1
  module ActionAuth
2
2
  class Configuration
3
3
 
4
+ attr_accessor :allow_user_deletion
5
+ attr_accessor :default_from_email
6
+ attr_accessor :magic_link_enabled
7
+ attr_accessor :verify_email_on_sign_in
4
8
  attr_accessor :webauthn_enabled
5
9
  attr_accessor :webauthn_origin
6
10
  attr_accessor :webauthn_rp_name
7
- attr_accessor :verify_email_on_sign_in
8
- attr_accessor :magic_link_enabled
9
- attr_accessor :default_from_email
11
+
10
12
 
11
13
  def initialize
14
+ @allow_user_deletion = true
15
+ @default_from_email = "from@example.com"
16
+ @magic_link_enabled = true
17
+ @verify_email_on_sign_in = true
12
18
  @webauthn_enabled = defined?(WebAuthn)
13
19
  @webauthn_origin = "http://localhost:3000"
14
20
  @webauthn_rp_name = Rails.application.class.to_s.deconstantize
15
- @verify_email_on_sign_in = true
16
- @magic_link_enabled = true
17
- @default_from_email = "from@example.com"
18
21
  end
19
22
 
20
- def webauthn_enabled?
21
- @webauthn_enabled.respond_to?(:call) ? @webauthn_enabled.call : @webauthn_enabled
23
+ def allow_user_deletion?
24
+ @allow_user_deletion.respond_to?(:call) ? @allow_user_deletion.call : @allow_user_deletion
22
25
  end
23
26
 
24
27
  def magic_link_enabled?
25
28
  @magic_link_enabled.respond_to?(:call) ? @magic_link_enabled.call : @magic_link_enabled
26
29
  end
27
30
 
31
+ def webauthn_enabled?
32
+ @webauthn_enabled.respond_to?(:call) ? @webauthn_enabled.call : @webauthn_enabled
33
+ end
34
+
28
35
  end
29
36
  end
@@ -1,3 +1,3 @@
1
1
  module ActionAuth
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Kimura
@@ -61,6 +61,7 @@ files:
61
61
  - app/controllers/action_auth/passwords_controller.rb
62
62
  - app/controllers/action_auth/registrations_controller.rb
63
63
  - app/controllers/action_auth/sessions_controller.rb
64
+ - app/controllers/action_auth/users_controller.rb
64
65
  - app/controllers/action_auth/webauthn_credential_authentications_controller.rb
65
66
  - app/controllers/action_auth/webauthn_credentials_controller.rb
66
67
  - app/helpers/action_auth/application_helper.rb