jj-middleware 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jj/middleware.rb +1 -1
- data/lib/jj/middleware/auth.rb +16 -2
- data/lib/jj/middleware/base.rb +6 -0
- data/lib/jj/middleware/onboarding.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e959ec144f88497c8f742f16d23957964a96aa41
|
4
|
+
data.tar.gz: c5cf533b9a706ef8fe6c1c0dce1142314abc0eb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5dec34b315931c2e3ac67bc20acfe672f56d4a6d14d3ff6cfa3d86c04a035aa50d7df9e63c810d6dbd79b2a4465ea51a17f0aaa6ae1f7eeba102017e43b5a42
|
7
|
+
data.tar.gz: 852538ad599e95875aea8353789d50e06da36f659d184279f8b0524fe61d4e9b0c539d9aa5cb1a5f28294de72717343eb8b185513cdcc172d82cdb1f16763e3d
|
data/lib/jj/middleware.rb
CHANGED
data/lib/jj/middleware/auth.rb
CHANGED
@@ -16,9 +16,23 @@ module JJ
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def logged_in?(sess)
|
19
|
-
|
19
|
+
unless sess.exist?
|
20
|
+
log.warn("[JJ::Auth] Session does not exist.")
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
|
20
24
|
user = sess.fetch("user")
|
21
|
-
|
25
|
+
if user.nil?
|
26
|
+
log.warn("[JJ::Auth] User key doesn't exist in session.")
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
|
30
|
+
unless user.id && user.email && user.model
|
31
|
+
log.warn("[JJ::Auth] User ID/Email/Model doesn't exist in session.")
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
|
35
|
+
true
|
22
36
|
end
|
23
37
|
end
|
24
38
|
end
|
data/lib/jj/middleware/base.rb
CHANGED
@@ -13,15 +13,21 @@ module JJ
|
|
13
13
|
sess = Session.new(env).fetch("user")
|
14
14
|
|
15
15
|
if sess.nil?
|
16
|
+
log.warn("[JJ::Onboarding] Session does not exist.")
|
16
17
|
return redirect("/login")
|
17
18
|
end
|
18
19
|
|
19
20
|
unless user_exist?(sess.id)
|
21
|
+
log.info("[JJ::Onboarding] User record not yet created.")
|
20
22
|
create_user!(sess.id)
|
23
|
+
log.info("[JJ::Onboarding] Redirect to Onboarding.")
|
21
24
|
return redirect("/onboarding")
|
22
25
|
end
|
23
26
|
|
24
|
-
|
27
|
+
unless sess.model.onboarded
|
28
|
+
log.info("[JJ::Onboarding] User yet to complete onboarding.")
|
29
|
+
return redirect("/onboarding")
|
30
|
+
end
|
25
31
|
|
26
32
|
@app.call(env)
|
27
33
|
end
|
@@ -30,6 +36,7 @@ module JJ
|
|
30
36
|
|
31
37
|
def create_user!(user_id)
|
32
38
|
Wes::Data::API::CreatorUser.create(:auth0_id => user_id)
|
39
|
+
log.info("[JJ::Onboarding] Created user record.")
|
33
40
|
end
|
34
41
|
|
35
42
|
def user_exist?(user_id)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jj-middleware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|