breath 0.1.3 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76b40953cb6e71c98a7870cc2a90360ff11e7dbfeeacb38ba02ec212ac8995d3
|
4
|
+
data.tar.gz: 7324b79742b9329015d3e527a6ed5c0abe5402e999933626fb912c2b004e017f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
34
|
+
send :render_401, e
|
33
35
|
end
|
34
36
|
|
35
37
|
# DELETE /schedule_kun/target/logout
|
data/lib/breath/version.rb
CHANGED
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
|
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-
|
11
|
+
date: 2023-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|