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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc55c292f0425ca3158d054001d53bd61f12e99c5dc43f8d2fc57262cfd367f2
4
- data.tar.gz: 7e4e9b6c6df39bf3070617119ff6e191a5e3519228b6693526bfbb8a6ea0bc53
3
+ metadata.gz: 56ac562d5ffc3b7bc21d0bb22dccc6c6a7ead70162c912b055d3999a5e2c1b8c
4
+ data.tar.gz: 380fe47309f87cfeb428a8e51964c7eb661f49b7c825169bb569a8edcc21ecef
5
5
  SHA512:
6
- metadata.gz: 7d5272797247572c2d7455b0be3556cfe7297691803d181c5d0cc77874642f59af78a884d5836f73d52a84734687c24ad34d49396e1185d41befc39d07c9f539
7
- data.tar.gz: e3d304b82778ed8762c39873dedfb530eeee1d7732db2156562bfb949efbfa23880f8667d6d5fb7862351453cb721a51fe70680ecd867c9e1c29f29a9b6c114d
6
+ metadata.gz: 316f8e4f88e655554ccb01c9e2be897dcfdbfaae1082b141a94fb973d4867a429cf836d0c3cd4abc9f2cbad4a2a1e505d4317846fde910ab49f1c3cc9cfbbb33
7
+ data.tar.gz: 9a8dbcb5645b15788f3bf3c8e1ed553c1174766193f48c27334d28763935bfe64e7adbab201821d03e5c1d1ba348f010920d5c31f0badfe0b3998000407dcb56
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![Build Status](https://travis-ci.org/melvinsembrano/lockie.svg?branch=master)](https://travis-ci.org/melvinsembrano/lockie)
2
+ [![Gem Version](https://badge.fury.io/rb/lockie.svg)](https://badge.fury.io/rb/lockie)
2
3
 
3
4
  # Lockie
4
5
  Short description and motivation.
@@ -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 = [:email_passwrd, :jwt]
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
@@ -1,3 +1,3 @@
1
1
  module Lockie
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
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.1.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