simply_auth 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/simply_auth/application_controller.rb +3 -0
- data/app/controllers/simply_auth/registrations_controller.rb +5 -0
- data/app/controllers/simply_auth/sessions_controller.rb +10 -1
- data/app/models/simply_auth/model.rb +8 -0
- data/app/views/simply_auth/registrations/_additional_fields.html.erb +0 -0
- data/app/views/simply_auth/registrations/new.html.erb +71 -14
- data/app/views/simply_auth/sessions/new.html.erb +57 -10
- data/lib/simply_auth/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1708669fe57a25f6504a5453fa443ec069d89d43
|
4
|
+
data.tar.gz: 8827d47aee99628c8af6f7ea66d60c114b4c7093
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dde691af02f93c295f2d75317c070aa3f0d235e55e58b497ec5c0cbe8dd8a7791a4535ac3a77569e2c2766107f31bc85ad92194eb106689d8a8cb0110d5036cd
|
7
|
+
data.tar.gz: 4e9c5e11b31351082c0fd70b882e08fe5414fcb90c25e19ce95d0648bec49f7d9916c0486beb653ac6d48fa8006719fc91999663b18a59860b4fb5bc8cf3417c
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module SimplyAuth
|
2
2
|
class SessionsController < ApplicationController
|
3
3
|
def new
|
4
|
-
@session = SimplyAuth::Session.new
|
4
|
+
@session = SimplyAuth::Session.new(permit_session_params)
|
5
|
+
end
|
6
|
+
|
7
|
+
def show
|
8
|
+
#handle refreshing on validation error
|
9
|
+
redirect_to new_session_path
|
5
10
|
end
|
6
11
|
|
7
12
|
def create
|
@@ -25,5 +30,9 @@ module SimplyAuth
|
|
25
30
|
def session_params
|
26
31
|
params.require(:session).permit(:email, :password)
|
27
32
|
end
|
33
|
+
|
34
|
+
def permit_session_params
|
35
|
+
params.permit(:session => [:email, :password])[:session]
|
36
|
+
end
|
28
37
|
end
|
29
38
|
end
|
@@ -63,6 +63,14 @@ module SimplyAuth
|
|
63
63
|
else
|
64
64
|
false
|
65
65
|
end
|
66
|
+
rescue RestClient::UnprocessableEntity => e
|
67
|
+
errors = JSON.parse(e.http_body)["errors"]
|
68
|
+
errors.each do |k, v|
|
69
|
+
v.each do |err|
|
70
|
+
self.errors.add(k, err)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
false
|
66
74
|
end
|
67
75
|
|
68
76
|
def self.owner_class
|
File without changes
|
@@ -1,15 +1,72 @@
|
|
1
|
-
|
2
|
-
<div class='
|
3
|
-
|
4
|
-
|
1
|
+
<div class='container'>
|
2
|
+
<div class='d-flex flex-row'>
|
3
|
+
<h2 class='mr-auto'>Sign Up</h2>
|
4
|
+
<div>
|
5
|
+
<span class='mr-2'>Already a member?</span>
|
6
|
+
<%= link_to "Log In", new_session_path, class: "btn btn-secondary" %>
|
7
|
+
</div>
|
5
8
|
</div>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<% end %>
|
9
|
+
<%= form_for @user, url: [:registrations], html: {class: "needs-validation", novalidate: true} do |f| %>
|
10
|
+
<div class='form-group'>
|
11
|
+
<%= f.label :name, "Name *" %>
|
12
|
+
<%= f.text_field :name, class: "form-control #{"is-invalid" if @user.errors[:name].any? }", required: true %>
|
13
|
+
<div class='invalid-feedback'>
|
14
|
+
<% if @user.errors[:name].any? %>
|
15
|
+
<%= @user.errors[:name].map{|m| "Name #{m}."}.join(" ") %>
|
16
|
+
<% else %>
|
17
|
+
Please provide your name.
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class='form-group'>
|
22
|
+
<%= f.label :email, "Email *" %>
|
23
|
+
<%= f.text_field :email, class: "form-control #{"is-invalid" if @user.errors[:email].any? }", required: true, type: :email %>
|
24
|
+
<div class='invalid-feedback'>
|
25
|
+
<% if @user.errors[:email].grep(/taken/).any? %>
|
26
|
+
That email is already registered. Would you like to <%= link_to "sign in", new_session_path(session: {email: @user.email}) %>?
|
27
|
+
<% elsif @user.errors[:email].any? %>
|
28
|
+
<%= @user.errors[:email].map{|m| "Email #{m}."}.join(" ") %>
|
29
|
+
<% else %>
|
30
|
+
Please provide your email.
|
31
|
+
<% end %>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
<div class='form-group'>
|
35
|
+
<%= f.label :password, "Password *" %>
|
36
|
+
<%= f.password_field :password, class: "form-control #{"is-invalid" if @user.errors[:password].any? }", required: true %>
|
37
|
+
<div class='invalid-feedback'>
|
38
|
+
<% if @user.errors[:password].any? %>
|
39
|
+
<%= @user.errors[:password].map{|m| "Password #{m}."}.join(" ") %>
|
40
|
+
<% else %>
|
41
|
+
Please provide a password.
|
42
|
+
<% end %>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
<%= render partial: "additional_fields", locals: {form: f} %>
|
46
|
+
<%= f.submit "Sign Up", class: "btn btn-primary" %>
|
47
|
+
<% end %>
|
48
|
+
|
49
|
+
<script>
|
50
|
+
(function() {
|
51
|
+
'use strict';
|
52
|
+
window.addEventListener('load', function() {
|
53
|
+
var forms = document.getElementsByClassName('needs-validation');
|
54
|
+
var validation = Array.prototype.filter.call(forms, function(form) {
|
55
|
+
form.addEventListener('submit', function(event) {
|
56
|
+
if (form.checkValidity() === false) {
|
57
|
+
event.preventDefault();
|
58
|
+
event.stopPropagation();
|
59
|
+
}
|
60
|
+
form.classList.add('was-validated');
|
61
|
+
}, false);
|
62
|
+
});
|
63
|
+
}, false);
|
64
|
+
})();
|
65
|
+
</script>
|
66
|
+
<style>
|
67
|
+
.field_with_errors ~ .invalid-feedback,
|
68
|
+
.field_with_errors ~ .invalid-tooltip {
|
69
|
+
display: block;
|
70
|
+
}
|
71
|
+
</style>
|
72
|
+
</div>
|
@@ -1,11 +1,58 @@
|
|
1
|
-
|
2
|
-
<div class='
|
3
|
-
|
4
|
-
|
1
|
+
<div class='container'>
|
2
|
+
<div class='d-flex flex-row'>
|
3
|
+
<h2 class='mr-auto'>Log In</h2>
|
4
|
+
<div>
|
5
|
+
<span class='mr-2'>Not a member?</span>
|
6
|
+
<%= link_to "Sign Up", new_registration_path, class: "btn btn-secondary" %>
|
7
|
+
</div>
|
5
8
|
</div>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<%
|
9
|
+
<%= form_for @session, url: :session, html: {class: "needs-validation", novalidate: true} do |f| %>
|
10
|
+
<div class='form-group'>
|
11
|
+
<%= f.label :email, "Email" %>
|
12
|
+
<%= f.text_field :email, class: "form-control #{"is-invalid" if @session.errors[:email].any? }", required: true, type: :email %>
|
13
|
+
<div class='invalid-feedback'>
|
14
|
+
<% if @session.errors[:email].any? %>
|
15
|
+
<%= @session.errors[:email].map{|m| "Email #{m}."}.join(" ") %>
|
16
|
+
<% else %>
|
17
|
+
Please provide your email.
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class='form-group'>
|
22
|
+
<%= f.label :password, "Password" %>
|
23
|
+
<%= f.password_field :password, class: "form-control #{"is-invalid" if @session.errors[:password].any? }", required: true %>
|
24
|
+
<div class='invalid-feedback'>
|
25
|
+
<% if @session.errors[:password].any? %>
|
26
|
+
<%= @session.errors[:password].map{|m| "Password #{m}."}.join(" ") %>
|
27
|
+
<% else %>
|
28
|
+
Please provide your password.
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<%= f.submit "Log In", class: "btn btn-primary"%>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
<script>
|
36
|
+
(function() {
|
37
|
+
'use strict';
|
38
|
+
window.addEventListener('load', function() {
|
39
|
+
var forms = document.getElementsByClassName('needs-validation');
|
40
|
+
var validation = Array.prototype.filter.call(forms, function(form) {
|
41
|
+
form.addEventListener('submit', function(event) {
|
42
|
+
if (form.checkValidity() === false) {
|
43
|
+
event.preventDefault();
|
44
|
+
event.stopPropagation();
|
45
|
+
}
|
46
|
+
form.classList.add('was-validated');
|
47
|
+
}, false);
|
48
|
+
});
|
49
|
+
}, false);
|
50
|
+
})();
|
51
|
+
</script>
|
52
|
+
<style>
|
53
|
+
.field_with_errors ~ .invalid-feedback,
|
54
|
+
.field_with_errors ~ .invalid-tooltip {
|
55
|
+
display: block;
|
56
|
+
}
|
57
|
+
</style>
|
58
|
+
</div>
|
data/lib/simply_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simply_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Fogle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- app/models/simply_auth/user.rb
|
78
78
|
- app/models/simply_auth/user_pool.rb
|
79
79
|
- app/views/layouts/simply_auth/application.html.erb
|
80
|
+
- app/views/simply_auth/registrations/_additional_fields.html.erb
|
80
81
|
- app/views/simply_auth/registrations/new.html.erb
|
81
82
|
- app/views/simply_auth/sessions/new.html.erb
|
82
83
|
- config/routes.rb
|