breath 0.1.3 → 0.2.1

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: 1cf89b5445e113d7198d4a9a9aa4ddfc1af8a09c0faec9eb4af344ad151b2af1
4
- data.tar.gz: 3efb2e128154bc6e7c0ecbfad3997d338f15d871f7c898d3ab943d53e7aecd91
3
+ metadata.gz: 76b40953cb6e71c98a7870cc2a90360ff11e7dbfeeacb38ba02ec212ac8995d3
4
+ data.tar.gz: 7324b79742b9329015d3e527a6ed5c0abe5402e999933626fb912c2b004e017f
5
5
  SHA512:
6
- metadata.gz: 1e267a0b8ec0aee65ad28e47d3c3e58daceddb9f37e019c6ea548e61906af86d413ab266c64b35a444c3bac4876c67cb27578a737984d79b8e9161dfdbc9f4d8
7
- data.tar.gz: 1b2d1fbbb58ac30cd6e7a3dd3283ba33f807724cf962e96f1cbc1b0c228bb7fcda18854ee27a368173616fc5bb46b373ab0162e3f3e401ee4e31c32c7ff88efc
6
+ metadata.gz: f9c1a788f8de0f6765fc943e721f6d468fc44a57174951c5b0a4e02b9fe93971bd194d835e407dcbc8dac905997a88b1bf22fbb8d6166cd8580ddba857b3af87
7
+ data.tar.gz: 53d89f967a23d992c47d9692f7c8cd9270a1f51422f9bfaf6b17b8a2d11d2cd53ba76eadc525ffd54d8b257e957910a3b089c913f1605dc2331e410dade80743
data/README.md CHANGED
@@ -86,6 +86,24 @@ end
86
86
  `Breath::ApplicationControllerHelper` intoroduce the user's authorization.<br/>
87
87
  `Breath::SessionsControllerHelper` introduce the actions `login`, and `logout`.
88
88
 
89
+ Then, you don't need write the codes to introduce authorizations.<br/>
90
+
91
+ You can use `current_user` method which is current logined user.
92
+
93
+ #### Route
94
+ Write `route.rb`
95
+ ```ruby
96
+ Rails.application.routes.draw do
97
+ breath :users
98
+
99
+ ...or...
100
+
101
+ breath :users do
102
+ get "test" => "sessions#test"
103
+ end
104
+ end
105
+ ```
106
+
89
107
  After you added these lines, show `bundle exec rails routes` command.<br/>
90
108
  You can see these routes are added.
91
109
  ```
@@ -93,8 +111,7 @@ GET /users/login
93
111
  POST /users/login
94
112
  DELETE /users/logout
95
113
  ```
96
-
97
- Then, you don't need write the codes to introduce authorizations.
114
+ Or, nested users routes.
98
115
 
99
116
  #### Config
100
117
  This plugin need cookie, and you can configure the cookie expires like bellow.<br/>
@@ -20,7 +20,7 @@ module Breath
20
20
 
21
21
  raise AuthenticationError if target.nil?
22
22
  rescue StandardError => e
23
- send :render_401, e.to_s
23
+ send :render_401, e
24
24
  end
25
25
 
26
26
  define_method current_target do
@@ -66,6 +66,12 @@ module Breath
66
66
 
67
67
  render json: res, status: 409
68
68
  end
69
+
70
+ def render_422(res)
71
+ Rails.logger.error error_message(res)
72
+
73
+ render json: res, status: 422
74
+ end
69
75
 
70
76
  def render_500(res)
71
77
  Rails.logger.error error_message(res)
@@ -7,6 +7,8 @@ module Breath
7
7
  class InvalidPassword < StandardError; end
8
8
 
9
9
  included do
10
+ rescue_from ActionController::InvalidAuthenticityToken, with: :render_422
11
+
10
12
  target_class = to_s.split("::")[-2].singularize.constantize
11
13
  target_name = target_class.to_s.underscore
12
14
  current_target = "current_#{target_name}"
@@ -29,7 +31,7 @@ module Breath
29
31
 
30
32
  render status: 200
31
33
  rescue StandardError => e
32
- send :render_401, e.to_s
34
+ send :render_401, e
33
35
  end
34
36
 
35
37
  # DELETE /schedule_kun/target/logout
@@ -1,3 +1,3 @@
1
1
  module Breath
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - testCodeV01
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-24 00:00:00.000000000 Z
11
+ date: 2023-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails