jj-middleware 0.3.1 → 0.4.0
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 +2 -2
- data/lib/jj/middleware/onboarding.rb +7 -11
- data/lib/jj/middleware/session.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54113726efff4acd9e0bc11693bb9e6e420cc6d4
|
4
|
+
data.tar.gz: 38d9b764429f1d9ecd643d94c28587ca53d406ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae7b8fec145fd36d705c99147e52deae4b6428b164b6a86f2b2bdcf7fb0801f08f28654dbd29dbfb8c5a81d3281fb22ccce075d8c2e6b9fd84e9252c51dafdbf
|
7
|
+
data.tar.gz: 8f26c9470e0579cb39b7d87a0096612e16f7ded51ba3a2bf4941db02fad4686e7eaf01d79937ca1870dce3d6498cb8c4c4caedf66bcbc6679d14a113f0337528
|
data/lib/jj/middleware.rb
CHANGED
data/lib/jj/middleware/auth.rb
CHANGED
@@ -27,8 +27,8 @@ module JJ
|
|
27
27
|
return false
|
28
28
|
end
|
29
29
|
|
30
|
-
unless user.id && user.email
|
31
|
-
log.warn("[JJ::Auth] User ID/Email
|
30
|
+
unless user.id && user.email
|
31
|
+
log.warn("[JJ::Auth] User ID/Email doesn't exist in session.")
|
32
32
|
return false
|
33
33
|
end
|
34
34
|
|
@@ -10,21 +10,17 @@ module JJ
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(env)
|
13
|
-
sess = Session.new(env)
|
13
|
+
sess = Session.new(env)
|
14
|
+
user = sess.fetch("user")
|
14
15
|
|
15
|
-
|
16
|
-
log.warn("[JJ::Onboarding] Session does not exist.")
|
17
|
-
return redirect("/login")
|
18
|
-
end
|
19
|
-
|
20
|
-
unless user_exist?(sess.id)
|
16
|
+
unless user_exist?(user.id)
|
21
17
|
log.info("[JJ::Onboarding] User record not yet created.")
|
22
|
-
create_user!(
|
23
|
-
|
18
|
+
record = create_user!(user.id)
|
19
|
+
sess.set_model(record)
|
24
20
|
return redirect("/onboarding")
|
25
21
|
end
|
26
22
|
|
27
|
-
unless
|
23
|
+
unless user.model.onboarded
|
28
24
|
log.info("[JJ::Onboarding] User yet to complete onboarding.")
|
29
25
|
return redirect("/onboarding")
|
30
26
|
end
|
@@ -35,8 +31,8 @@ module JJ
|
|
35
31
|
private
|
36
32
|
|
37
33
|
def create_user!(user_id)
|
38
|
-
Wes::Data::API::CreatorUser.create(:auth0_id => user_id)
|
39
34
|
log.info("[JJ::Onboarding] Created user record.")
|
35
|
+
Wes::Data::API::CreatorUser.create(:auth0_id => user_id)
|
40
36
|
end
|
41
37
|
|
42
38
|
def user_exist?(user_id)
|