nyauth 0.3.0 → 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/nyauth/confirmation_requests_controller.rb +12 -9
- data/app/controllers/nyauth/registrations_controller.rb +7 -7
- data/app/controllers/nyauth/reset_password_requests_controller.rb +12 -9
- data/app/controllers/nyauth/sessions_controller.rb +7 -7
- data/app/services/nyauth/confirmation_request.rb +19 -0
- data/app/services/nyauth/registration.rb +22 -0
- data/app/services/nyauth/reset_password_request.rb +19 -0
- data/app/services/nyauth/{session_service.rb → session.rb} +4 -4
- data/app/views/nyauth/confirmation_requests/new.html.erb +1 -1
- data/app/views/nyauth/registrations/new.html.erb +1 -1
- data/app/views/nyauth/reset_password_requests/new.html.erb +1 -1
- data/app/views/nyauth/sessions/new.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/lib/nyauth/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +3645 -0
- data/spec/dummy/log/test.log +10449 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/featrues/nyauth/confirmation_requests_spec.rb +2 -2
- data/spec/featrues/nyauth/registrations_spec.rb +3 -3
- data/spec/featrues/nyauth/reset_password_requests_spec.rb +2 -2
- data/spec/featrues/nyauth/sessions_spec.rb +6 -6
- data/spec/lib/generators/nyauth/tmp/app/views/nyauth/confirmation_requests/new.html.erb +1 -1
- data/spec/lib/generators/nyauth/tmp/app/views/nyauth/registrations/new.html.erb +1 -1
- data/spec/lib/generators/nyauth/tmp/app/views/nyauth/reset_password_requests/new.html.erb +1 -1
- data/spec/lib/generators/nyauth/tmp/app/views/nyauth/sessions/new.html.erb +1 -1
- metadata +8 -4
- data/app/services/nyauth/confirmation_request_service.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b179e705b0291eb4ab1cb5ceb28ed1ab60f6c36e
|
4
|
+
data.tar.gz: 789c2faca7c10305ecfdef41985394aeca889a4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae1e764608c2e31037aef15d9e52038f70de3f40b37998c30128078013abdb619a412c52ae63c073ed5fdd9280eb954a1c2bd498666eb251dfc5754e0efb3586
|
7
|
+
data.tar.gz: de4269ccf19ad4fb969f05f3b0ae33ca0fbdd846032f3f688c7fc182b0deb6f70a215ba0c6e74f471659a9dbba26c65c77fcd1db2afe84e500598a42912ba529
|
@@ -4,27 +4,30 @@ module Nyauth
|
|
4
4
|
allow_everyone
|
5
5
|
self.responder = Nyauth::AppResponder
|
6
6
|
respond_to :html, :json
|
7
|
-
before_action :
|
8
|
-
after_action :send_mail, only: [:create], if: -> { @
|
7
|
+
before_action :set_service
|
8
|
+
after_action :send_mail, only: [:create], if: -> { @service.errors.blank? }
|
9
9
|
|
10
10
|
def new
|
11
11
|
end
|
12
12
|
|
13
13
|
def create
|
14
|
-
@
|
15
|
-
respond_with(@
|
14
|
+
@service.save(as: nyauth_client_name)
|
15
|
+
respond_with(@service, location: Nyauth.configuration.redirect_path_after_create_request_confirmation.call(nyauth_client_name) || main_app.root_path)
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
def
|
21
|
-
@
|
22
|
-
|
23
|
-
|
20
|
+
def set_service
|
21
|
+
@service = Nyauth::ConfirmationRequest.new(confirmation_request_params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def confirmation_request_params
|
25
|
+
params.fetch(:confirmation_request, {})
|
26
|
+
.permit(:email)
|
24
27
|
end
|
25
28
|
|
26
29
|
def send_mail
|
27
|
-
Nyauth::RequestMailer.request_confirmation(@client).deliver_now
|
30
|
+
Nyauth::RequestMailer.request_confirmation(@service.client).deliver_now
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
@@ -4,24 +4,24 @@ module Nyauth
|
|
4
4
|
allow_everyone
|
5
5
|
self.responder = Nyauth::AppResponder
|
6
6
|
respond_to :html, :json
|
7
|
-
before_action :
|
7
|
+
before_action :set_service
|
8
8
|
|
9
9
|
def new
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
13
|
-
sign_in(@client) if @
|
14
|
-
respond_with
|
13
|
+
sign_in(@service.client) if @service.save(as: nyauth_client_name)
|
14
|
+
respond_with @service, location: Nyauth.configuration.redirect_path_after_registration.call(nyauth_client_name) || main_app.root_path
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
def
|
20
|
-
@
|
19
|
+
def set_service
|
20
|
+
@service = Nyauth::Registration.new(registration_params)
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
params.fetch(
|
23
|
+
def registration_params
|
24
|
+
params.fetch(:registration, {})
|
25
25
|
.permit(:email, :password, :password_confirmation)
|
26
26
|
end
|
27
27
|
end
|
@@ -4,27 +4,30 @@ module Nyauth
|
|
4
4
|
allow_everyone
|
5
5
|
self.responder = Nyauth::AppResponder
|
6
6
|
respond_to :html, :json
|
7
|
-
before_action :
|
8
|
-
after_action :send_mail, only: [:create], if: -> { @
|
7
|
+
before_action :set_service
|
8
|
+
after_action :send_mail, only: [:create], if: -> { @service.errors.blank? }
|
9
9
|
|
10
10
|
def new
|
11
11
|
end
|
12
12
|
|
13
13
|
def create
|
14
|
-
@
|
15
|
-
respond_with(@
|
14
|
+
@service.save(as: nyauth_client_name)
|
15
|
+
respond_with(@service, location: Nyauth.configuration.redirect_path_after_reset_password_request.call(nyauth_client_name) || main_app.root_path)
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
def
|
21
|
-
@
|
22
|
-
|
23
|
-
|
20
|
+
def set_service
|
21
|
+
@service = Nyauth::ResetPasswordRequest.new(reset_password_request_params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def reset_password_request_params
|
25
|
+
params.fetch(:reset_password_request, {})
|
26
|
+
.permit(:email)
|
24
27
|
end
|
25
28
|
|
26
29
|
def send_mail
|
27
|
-
Nyauth::RequestMailer.request_reset_password(@client).deliver_now
|
30
|
+
Nyauth::RequestMailer.request_reset_password(@service.client).deliver_now
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
@@ -5,15 +5,15 @@ module Nyauth
|
|
5
5
|
allow_everyone only: [:new, :create]
|
6
6
|
self.responder = Nyauth::AppResponder
|
7
7
|
respond_to :html, :json
|
8
|
-
before_action :
|
8
|
+
before_action :set_service
|
9
9
|
|
10
10
|
def new
|
11
11
|
end
|
12
12
|
|
13
13
|
def create
|
14
|
-
sign_in(@
|
14
|
+
sign_in(@service.client) if @service.save(as: nyauth_client_name)
|
15
15
|
redirect_path = session.delete("#{nyauth_client_name}_return_to")
|
16
|
-
respond_with @
|
16
|
+
respond_with @service,
|
17
17
|
location: redirect_path || \
|
18
18
|
Nyauth.configuration.redirect_path_after_sign_in.call(nyauth_client_name) || \
|
19
19
|
main_app.root_path
|
@@ -21,17 +21,17 @@ module Nyauth
|
|
21
21
|
|
22
22
|
def destroy
|
23
23
|
sign_out
|
24
|
-
respond_with @
|
24
|
+
respond_with @service, location: Nyauth.configuration.redirect_path_after_sign_out.call(nyauth_client_name) || new_session_path_for(nyauth_client_name)
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def
|
30
|
-
@
|
29
|
+
def set_service
|
30
|
+
@service = Nyauth::Session.new(session_service_params)
|
31
31
|
end
|
32
32
|
|
33
33
|
def session_service_params
|
34
|
-
params.fetch(:
|
34
|
+
params.fetch(:session, {})
|
35
35
|
.permit(:email, :password)
|
36
36
|
end
|
37
37
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Nyauth
|
2
|
+
class ConfirmationRequest
|
3
|
+
include ActiveModel::Model
|
4
|
+
attr_reader :email, :client
|
5
|
+
|
6
|
+
def initialize(service_params = {})
|
7
|
+
@email = service_params[:email]
|
8
|
+
end
|
9
|
+
|
10
|
+
def save(options = {})
|
11
|
+
options.reverse_merge!(as: :user)
|
12
|
+
klass = options[:as].to_s.classify.constantize
|
13
|
+
@client = klass.find_by!(email: @email)
|
14
|
+
@client.request_confirmation
|
15
|
+
rescue
|
16
|
+
errors.add(:base, :invalid_email)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Nyauth
|
2
|
+
class Registration
|
3
|
+
include ActiveModel::Model
|
4
|
+
attr_reader :email, :password, :password_confirmation, :client
|
5
|
+
|
6
|
+
def initialize(service_params = {})
|
7
|
+
@email = service_params[:email]
|
8
|
+
@password = service_params[:password]
|
9
|
+
@password_confirmation = service_params[:password_confirmation]
|
10
|
+
end
|
11
|
+
|
12
|
+
def save(options = {})
|
13
|
+
options.reverse_merge!(as: :user)
|
14
|
+
klass = options[:as].to_s.classify.constantize
|
15
|
+
@client = klass.create(email: @email,
|
16
|
+
password: @password,
|
17
|
+
password_confirmation: @password_confirmation)
|
18
|
+
@errors = @client.errors
|
19
|
+
@client.valid?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Nyauth
|
2
|
+
class ResetPasswordRequest
|
3
|
+
include ActiveModel::Model
|
4
|
+
attr_reader :email, :client
|
5
|
+
|
6
|
+
def initialize(service_params = {})
|
7
|
+
@email = service_params[:email]
|
8
|
+
end
|
9
|
+
|
10
|
+
def save(options = {})
|
11
|
+
options.reverse_merge!(as: :user)
|
12
|
+
klass = options[:as].to_s.classify.constantize
|
13
|
+
@client = klass.find_by!(email: @email)
|
14
|
+
@client.request_reset_password
|
15
|
+
rescue
|
16
|
+
errors.add(:base, :invalid_email)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Nyauth
|
2
|
-
class
|
2
|
+
class Session
|
3
3
|
include ActiveModel::Model
|
4
4
|
attr_reader :email, :password, :client
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@email =
|
8
|
-
@password =
|
6
|
+
def initialize(service_params = {})
|
7
|
+
@email = service_params[:email]
|
8
|
+
@password = service_params[:password]
|
9
9
|
end
|
10
10
|
|
11
11
|
def save(options = {})
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for
|
1
|
+
<%= form_for @service, url: confirmation_requests_path_for(nyauth_client_name) do |f| %>
|
2
2
|
<%= f.email_field :email %>
|
3
3
|
<%= f.submit 'request confirmation' %>
|
4
4
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for @
|
1
|
+
<%= form_for @service, url: registration_path_for(nyauth_client_name) do |f| %>
|
2
2
|
<%= f.object.errors.full_messages.join ',' %>
|
3
3
|
<%= f.email_field :email %>
|
4
4
|
<%= f.password_field :password %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for
|
1
|
+
<%= form_for @service, url: reset_password_requests_path_for(nyauth_client_name) do |f| %>
|
2
2
|
<%= f.text_field :email %>
|
3
3
|
<%= f.submit 'reset password' %>
|
4
4
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for @
|
1
|
+
<%= form_for @service, url: session_path_for(nyauth_client_name) do |f| %>
|
2
2
|
<%= f.object.errors.full_messages.join ',' %>
|
3
3
|
<%= f.email_field :email %>
|
4
4
|
<%= f.password_field :password %>
|
data/config/locales/en.yml
CHANGED
data/config/locales/ja.yml
CHANGED
data/lib/nyauth/version.rb
CHANGED
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|