lockie 0.2.0 → 0.2.1

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: 56ac562d5ffc3b7bc21d0bb22dccc6c6a7ead70162c912b055d3999a5e2c1b8c
4
- data.tar.gz: 380fe47309f87cfeb428a8e51964c7eb661f49b7c825169bb569a8edcc21ecef
3
+ metadata.gz: 5611c39c34639b730d1e727ac9d19d9606e54a34a289f3dedf863a83d71175c5
4
+ data.tar.gz: f25907b964058f449210ace1e8b1d91cc7ea35f7b0972fc2ffb358c004aa7c58
5
5
  SHA512:
6
- metadata.gz: 316f8e4f88e655554ccb01c9e2be897dcfdbfaae1082b141a94fb973d4867a429cf836d0c3cd4abc9f2cbad4a2a1e505d4317846fde910ab49f1c3cc9cfbbb33
7
- data.tar.gz: 9a8dbcb5645b15788f3bf3c8e1ed553c1174766193f48c27334d28763935bfe64e7adbab201821d03e5c1d1ba348f010920d5c31f0badfe0b3998000407dcb56
6
+ metadata.gz: '08027dfcd40444551b9a561634dc9f192facea3d496d5a144b6c62840c45e781d56fba32f213d14eb99ffbbba7d1c7aef43ae96529c8032a4faa7360027ab679'
7
+ data.tar.gz: 2007a0a5ecb0c78f732db3c9875dd0419c5e18242b2431e265d9cf9e3be8f45cd3f40a9e1c563c5c4be264102f0809bdc771d32ab49b187ea0c025e5e11b2e65
data/README.md CHANGED
@@ -2,10 +2,8 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/lockie.svg)](https://badge.fury.io/rb/lockie)
3
3
 
4
4
  # Lockie
5
- Short description and motivation.
5
+ A drop-in, none assuming warden based Password and JWT authentication for Rails 5.2++
6
6
 
7
- ## Usage
8
- How to use my plugin.
9
7
 
10
8
  ## Installation
11
9
  Add this line to your application's Gemfile:
@@ -19,9 +17,57 @@ And then execute:
19
17
  $ bundle
20
18
  ```
21
19
 
22
- Or install it yourself as:
23
- ```bash
24
- $ gem install lockie
20
+ ## Usage
21
+ Add the following lines to your authenticaiton model e.g. `User`:
22
+
23
+ ```ruby
24
+ has_secure_password
25
+ include Lockie::ModelHelper
26
+ ```
27
+
28
+ Add the following lines to your base controller e.g. `ApplicationController`:
29
+ ```ruby
30
+ include Lockie::ControllerHelper
31
+ before_action :authenticate!
32
+ ```
33
+ That's it! All your controllers that inherits `ApplicationController` are now protected.
34
+
35
+
36
+ ## Adding a session controller
37
+ Creating a session controller is simple as:
38
+
39
+ Session controller
40
+ ```ruby
41
+ class SessionController < ApplicationController
42
+ skip_before_action :authenticate!, only: [:new]
43
+
44
+ def create
45
+ # on successful login redirect to your user's page
46
+ redirect_to root_url
47
+ end
48
+
49
+ def destroy
50
+ logout
51
+ redirect_to login_url
52
+ end
53
+ end
54
+
55
+ ```
56
+
57
+ routes.rb
58
+ ```ruby
59
+ get 'login' => 'session#new'
60
+ post 'login' => 'session#create'
61
+ get 'logout' => 'session#destroy'
62
+ ```
63
+
64
+ session/new.html.erb view:
65
+ ```ruby
66
+ <%= form_tag(login_url) do -%>
67
+ <%= email_field_tag 'email' %>
68
+ <%= password_field_tag 'password' %>
69
+ <%= submit_tag "Login" %>
70
+ <% end -%>
25
71
  ```
26
72
 
27
73
  ## Contributing
@@ -4,7 +4,7 @@ module Lockie
4
4
 
5
5
  included do
6
6
  if respond_to?(:helper_method)
7
- helper_method :current_user
7
+ helper_method "current_#{ Lockie.config.model_name.underscore }".to_sym
8
8
  helper_method :logged_in?
9
9
  helper_method :authenticated?
10
10
  end
@@ -14,7 +14,7 @@ module Lockie
14
14
  env['warden']
15
15
  end
16
16
 
17
- def current_user(*args)
17
+ define_method "current_#{ Lockie.config.model_name.underscore }".to_sym do |*args|
18
18
  warden.user(*args)
19
19
  end
20
20
 
@@ -1,3 +1,3 @@
1
1
  module Lockie
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Melvin Sembrano