lockie 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/lockie.rb +2 -1
- data/lib/lockie/controller_helper.rb +41 -0
- data/lib/lockie/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56ac562d5ffc3b7bc21d0bb22dccc6c6a7ead70162c912b055d3999a5e2c1b8c
|
4
|
+
data.tar.gz: 380fe47309f87cfeb428a8e51964c7eb661f49b7c825169bb569a8edcc21ecef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 316f8e4f88e655554ccb01c9e2be897dcfdbfaae1082b141a94fb973d4867a429cf836d0c3cd4abc9f2cbad4a2a1e505d4317846fde910ab49f1c3cc9cfbbb33
|
7
|
+
data.tar.gz: 9a8dbcb5645b15788f3bf3c8e1ed553c1174766193f48c27334d28763935bfe64e7adbab201821d03e5c1d1ba348f010920d5c31f0badfe0b3998000407dcb56
|
data/README.md
CHANGED
data/lib/lockie.rb
CHANGED
@@ -3,6 +3,7 @@ require 'warden'
|
|
3
3
|
require_relative "lockie/rails"
|
4
4
|
require_relative "lockie/log_helper"
|
5
5
|
require_relative "lockie/model_helper"
|
6
|
+
require_relative "lockie/controller_helper"
|
6
7
|
require_relative "lockie/strategies/email_password"
|
7
8
|
require_relative "lockie/strategies/jwt"
|
8
9
|
require_relative "lockie/strategies/failed"
|
@@ -20,7 +21,7 @@ module Lockie
|
|
20
21
|
def initialize
|
21
22
|
@model_name = "User"
|
22
23
|
@unauthenticated_path = "/login"
|
23
|
-
@default_strategies = [:
|
24
|
+
@default_strategies = [:email_password, :jwt]
|
24
25
|
@hash_algorithm = "HS256"
|
25
26
|
end
|
26
27
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Lockie
|
2
|
+
module ControllerHelper
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
if respond_to?(:helper_method)
|
7
|
+
helper_method :current_user
|
8
|
+
helper_method :logged_in?
|
9
|
+
helper_method :authenticated?
|
10
|
+
end
|
11
|
+
|
12
|
+
def warden
|
13
|
+
return request.env['warden'] if defined?(request)
|
14
|
+
env['warden']
|
15
|
+
end
|
16
|
+
|
17
|
+
def current_user(*args)
|
18
|
+
warden.user(*args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def authenticate!(scope = warden.config.default_scope)
|
22
|
+
warden.authenticate!({ scope: scope }.compact)
|
23
|
+
end
|
24
|
+
|
25
|
+
def authenticate(scope = warden.config.default_scope)
|
26
|
+
warden.authenticate({ scope: scope }.compact)
|
27
|
+
end
|
28
|
+
|
29
|
+
def authenticated?(*args)
|
30
|
+
warden.authenticated?(*args)
|
31
|
+
end
|
32
|
+
alias logged_in? authenticated?
|
33
|
+
|
34
|
+
def logout(*args)
|
35
|
+
authenticated?(args)
|
36
|
+
warden.logout
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/lockie/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lockie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Melvin Sembrano
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- lib/lockie.rb
|
108
|
+
- lib/lockie/controller_helper.rb
|
108
109
|
- lib/lockie/failure_app.rb
|
109
110
|
- lib/lockie/log_helper.rb
|
110
111
|
- lib/lockie/model_helper.rb
|