auth_master 0.0.4 → 0.0.5

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: c266d6e5222227d0f002f1ed663a9420d599d9f3456d082f3de21473f2c6af25
4
- data.tar.gz: 68ef46005182ad74059391ad7df9f869099ae381b5b7913224f6fcdfe17cbcdd
3
+ metadata.gz: af811daf24f09f98a0a9c93aa4eba5f7fbebafe0a08f1fc68f3ce11491de2c14
4
+ data.tar.gz: 90418adf94d7341733371256330cb504c956aac0b358d4b1b323a5a220220056
5
5
  SHA512:
6
- metadata.gz: c16626eee3bf0fbbe5b2e6db7beea09a9a27d2785450ef50c4a572bd60b4fd1be9cf313100308b3cd1cc483555fd48fed06e936f4bda5aaf5f1400cf863cc41d
7
- data.tar.gz: 735d46ca1a99308be75b5891df5203c9b63c1b8459312d63d5de623b77322204526b49958842f6983ae35744f785a803e9e5cd4b8de40a65f30e2ad459bdf898
6
+ metadata.gz: 4f5fe2fc28562f1128a3f41e9a783b6b7983dac6753215d69629d3faea0ebf5148bde172f8afbe634a188825cd3422584179cf1b903f09ed74618f6224dbfa9b
7
+ data.tar.gz: fae32da2226266542bb294e57f925b86ab5d29a50073ee23fa6d394b91066b5cb606bb1d357b7e260ea93c94039e381fff8e50589d0f44e139e771c78be70e0d
@@ -35,6 +35,18 @@ module AuthMaster
35
35
  session.delete(session_key)
36
36
  session[target_session_key] = auth_master_session.id
37
37
 
38
+ # TODO: Use config for
39
+ # a) session key;
40
+ # b) default redirect path
41
+ saved_path = session.delete("redirect_to")
42
+ redirect_to(saved_path || "/")
43
+ end
44
+
45
+ def destroy
46
+ auth_master_session_id = session.delete(target_session_key)
47
+ AuthMaster::LogoutOperation.call!(auth_master_session_id)
48
+
49
+ # TODO: Use config for redirect_path
38
50
  redirect_to("/")
39
51
  end
40
52
 
@@ -2,6 +2,6 @@ module AuthMaster
2
2
  class Session < ApplicationRecord
3
3
  belongs_to :target, polymorphic: true
4
4
 
5
- enum :status, [ :inactive, :active ], default: :inactive
5
+ enum :status, [ :inactive, :active, :logout ], default: :inactive
6
6
  end
7
7
  end
@@ -0,0 +1,10 @@
1
+ module AuthMaster
2
+ class LogoutOperation < AuthMaster::AbstractOperation
3
+ def self.call!(auth_master_session_id)
4
+ auth_master_session = AuthMaster::Session.active.find_by(id: auth_master_session_id)
5
+ return if auth_master_session.blank?
6
+
7
+ AuthMaster::SessionService.logout!(auth_master_session)
8
+ end
9
+ end
10
+ end
@@ -16,8 +16,13 @@ module AuthMaster
16
16
  end
17
17
 
18
18
  def activate!(auth_master_session)
19
+ # TODO: Save IP Address, User Agent, etc
19
20
  auth_master_session.active!
21
+ end
22
+
23
+ def logout!(auth_master_session)
20
24
  # TODO: Save IP Address, User Agent, etc
25
+ auth_master_session.logout!
21
26
  end
22
27
 
23
28
  private
data/config/routes.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  AuthMaster::Engine.routes.draw do
2
- get "/:target/login", to: "sessions#new", as: :auth_master_login
3
- post "/:target/login", to: "sessions#create"
4
-
5
- get "/:target/sent", to: "sessions#sent", as: :auth_master_sent
6
-
7
- get "/:target/link", to: "sessions#link", as: :auth_master_link
8
- post "/:target/link", to: "sessions#activate"
9
-
10
- get "/:target/denied", to: "sessions#denied", as: :auth_master_denied
2
+ get "/:target/login", to: "sessions#new", as: :auth_master_login
3
+ post "/:target/login", to: "sessions#create"
4
+ get "/:target/sent", to: "sessions#sent", as: :auth_master_sent
5
+ get "/:target/link", to: "sessions#link", as: :auth_master_link
6
+ post "/:target/link", to: "sessions#activate"
7
+ get "/:target/denied", to: "sessions#denied", as: :auth_master_denied
8
+ delete "/:target/logout", to: "sessions#destroy", as: :auth_master_logout
11
9
  end
@@ -1,3 +1,3 @@
1
1
  module AuthMaster
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - vickodin
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-29 00:00:00.000000000 Z
10
+ date: 2025-03-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -64,6 +64,7 @@ files:
64
64
  - app/models/auth_master/session.rb
65
65
  - app/operations/auth_master/abstract_operation.rb
66
66
  - app/operations/auth_master/check_link_operation.rb
67
+ - app/operations/auth_master/logout_operation.rb
67
68
  - app/operations/auth_master/send_link_operation.rb
68
69
  - app/services/auth_master/session_service.rb
69
70
  - app/views/auth_master/sessions/link.html.erb