console_creep 0.1.0 → 0.3.0
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: d112068dfc26c9cfe1d998f0922a4ae3d5dcfa3f7c9530eb8c3ec6d78e25a66d
|
4
|
+
data.tar.gz: bc56a4e7f298817f14a391850223638f71e45261dc2cf266f72c3d04d9bc39d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aef5439225655d1d0b4d3fd7797ef31d4c90fecc011e5724a3363020dd19e7d31952ec550fe7a45cafbe67d6a405655cb3a79d95ec2fbb2cb0d68095be0118b3
|
7
|
+
data.tar.gz: 2357f5f55fc32f0a4c90671e3f21b6f228776785dd2a5ff95aa5f1006979c9424313f233d6e0584b1ee66acfaa94be0aeb04953519b002cf5b77da421387144c
|
data/README.md
CHANGED
@@ -49,16 +49,24 @@ ConsoleCreep.setup do |config|
|
|
49
49
|
# options are `:error`, `:result`, `:command`
|
50
50
|
# config.store = :database, { model: 'ConsoleCreepLog', except: [:result] }
|
51
51
|
|
52
|
-
##
|
53
|
-
#
|
52
|
+
## Authentication
|
53
|
+
#
|
54
|
+
# Defaults to :devise but there is no other one at the moment.
|
55
|
+
# Create your own. See `lib/authenticators/devise_authenticator.rb``
|
56
|
+
#
|
57
|
+
# Use the devise authenticator and use a custom class:
|
58
|
+
# config.authenticator = :devise, { class: "AdminUser" }
|
59
|
+
#
|
60
|
+
# or use a proc:
|
61
|
+
# config.authenticator = :devise, { if: ->(user) { user.admin? } }
|
62
|
+
|
63
|
+
## Welcome Message
|
64
|
+
#
|
65
|
+
# Change the welcome message.
|
66
|
+
# config.welcome = ->(user) { "hey user #{user}" }
|
54
67
|
|
55
68
|
## Enabled for the logged-in user (default is true)
|
56
69
|
# config.log_for_user = ->(user) { !user.doctor? }
|
57
|
-
|
58
|
-
## Change the authentication scheme
|
59
|
-
# config.authenticator = :devise
|
60
|
-
# if your class name is Admin:
|
61
|
-
# config.authenticator = :devise, { class: 'Admin' }
|
62
70
|
end
|
63
71
|
```
|
64
72
|
|
@@ -24,8 +24,18 @@ module ConsoleCreep
|
|
24
24
|
print 'Password: '
|
25
25
|
pass = $stdin.noecho(&:gets)
|
26
26
|
if user.valid_password?(pass.strip)
|
27
|
-
|
28
|
-
|
27
|
+
if @options[:if]
|
28
|
+
if @options[:if].call(user)
|
29
|
+
set_current_user(user)
|
30
|
+
ConsoleCreep.config.welcome.call(user)
|
31
|
+
else
|
32
|
+
puts "User not admin."
|
33
|
+
die
|
34
|
+
end
|
35
|
+
else
|
36
|
+
set_current_user(user)
|
37
|
+
ConsoleCreep.config.welcome.call(user)
|
38
|
+
end
|
29
39
|
else
|
30
40
|
puts 'Provided password is not correct! Exiting...'
|
31
41
|
die
|
data/lib/console_creep/config.rb
CHANGED
@@ -18,14 +18,19 @@ module ConsoleCreep
|
|
18
18
|
@enabled = Rails.env.production?
|
19
19
|
end
|
20
20
|
|
21
|
-
def authenticator=(
|
22
|
-
|
21
|
+
def authenticator=(args)
|
22
|
+
klass = args.first
|
23
23
|
options = args.extract_options!
|
24
|
+
if klass == :devise
|
25
|
+
auth_class = Authenticators::DeviseAuthenticator
|
26
|
+
else
|
27
|
+
auth_class = klass.to_s.constantize
|
28
|
+
end
|
24
29
|
@authenticator = auth_class.new(options)
|
25
30
|
end
|
26
31
|
|
27
|
-
def store=(
|
28
|
-
store_class = args.
|
32
|
+
def store=(args)
|
33
|
+
store_class = args.first
|
29
34
|
options = args.extract_options!
|
30
35
|
klass = if store_class == :database
|
31
36
|
Stores::DatabaseStore
|