authentication-zero 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26fe7423bf85a359fb127c86bd15edbc28e764e8e909c22dfb38e592f6c6b76d
|
4
|
+
data.tar.gz: f008ffe4350af35e63ba90d300ac58e2f9e7a0d7589703f0c433509fbe747cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15f85ad77fa48009b89d73ad826fc38594d47475c14b131af01b0ecc31f33e41549496515709b4b9236cd9d94dd7412b836fac7dd6977a3780b1a82081c13327
|
7
|
+
data.tar.gz: 68d79e565a3fad1335b4de13b5352853ba5609b854617bc893f495e19207ec5aae15a8bdffbac8bb6af40d2a64c0054f59b654d8b8975f66653fe3b80eb549c6
|
data/Gemfile.lock
ADDED
data/README.md
CHANGED
@@ -4,10 +4,47 @@ The purpose of authentication zero is to generate a pre-built authentication sys
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
Add this
|
7
|
+
Add this lines to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem
|
10
|
+
gem "bcrypt"
|
11
|
+
gem "authentication-zero"
|
12
|
+
```
|
13
|
+
|
14
|
+
Then run `bundle install`
|
15
|
+
|
16
|
+
You'll need to set the root path in your routes.rb, for this example let's use the following:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
root "home#index"
|
20
|
+
```
|
21
|
+
|
22
|
+
```
|
23
|
+
$ rails generate controller home index
|
24
|
+
```
|
25
|
+
|
26
|
+
Add these lines to your `app/views/home/index.html.erb`:
|
27
|
+
|
28
|
+
```html+erb
|
29
|
+
<p style="color: green"><%= notice %></p>
|
30
|
+
|
31
|
+
<p>Signed as <%= Current.user.email %></p>
|
32
|
+
|
33
|
+
<div>
|
34
|
+
<%= link_to "Change password", password_edit_path %>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div>
|
38
|
+
<%= link_to "Cancel my account & delete my data", cancellation_new_path %>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<%= button_to "Log out", sign_out_path, method: :delete %>
|
42
|
+
```
|
43
|
+
|
44
|
+
And you'll need to set up the default URL options for the mailer in each environment. Here is a possible configuration for `config/environments/development.rb`:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
11
48
|
```
|
12
49
|
|
13
50
|
## Usage
|
@@ -5,10 +5,6 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
5
5
|
|
6
6
|
source_root File.expand_path("templates", __dir__)
|
7
7
|
|
8
|
-
def uncomment_bcrypt
|
9
|
-
uncomment_lines 'Gemfile', /bcrypt/
|
10
|
-
end
|
11
|
-
|
12
8
|
def create_controllers
|
13
9
|
directory "controllers/html", "app/controllers"
|
14
10
|
end
|
@@ -47,17 +43,17 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
47
43
|
end
|
48
44
|
|
49
45
|
def add_application_controller_methods
|
50
|
-
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", verbose: false do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
46
|
+
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", verbose: false do <<-CODE
|
47
|
+
before_action :authenticate
|
48
|
+
|
49
|
+
private
|
50
|
+
def authenticate
|
51
|
+
if #{singular_table_name} = cookies[:session_token] && #{class_name}.find_by_session_token(cookies[:session_token])
|
52
|
+
Current.user = #{singular_table_name}
|
53
|
+
else
|
54
|
+
redirect_to sign_in_path, alert: "You need to sign in or sign up before continuing"
|
55
|
+
end
|
56
|
+
end
|
61
57
|
CODE
|
62
58
|
end
|
63
59
|
end
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
9
9
|
|
10
10
|
<ul>
|
11
|
-
<%%
|
11
|
+
<%% @<%= singular_table_name %>.errors.each do |error| %>
|
12
12
|
<li><%%= error.full_message %></li>
|
13
13
|
<%% end %>
|
14
14
|
</ul>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authentication-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
@@ -21,6 +21,7 @@ files:
|
|
21
21
|
- CHANGELOG.md
|
22
22
|
- CODE_OF_CONDUCT.md
|
23
23
|
- Gemfile
|
24
|
+
- Gemfile.lock
|
24
25
|
- LICENSE.txt
|
25
26
|
- README.md
|
26
27
|
- Rakefile
|