credible 0.10.0 → 0.11.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: ea406004a9c14011202b1a455928cb1cfc78fb042e7cd04f566b2139db774a15
4
- data.tar.gz: a820ef53bdd6459e3bc42f0ed56d60014a2d7d11a7033d74ada97fefcb4a7f2c
3
+ metadata.gz: 3600f170c11397baf11f7b350fdc1bcfe5fa9eff0c447743e145affdfb33d2d2
4
+ data.tar.gz: 1ab495351756b77d942082e1c31c4327154041575e9d1ce35ee519943d9edd7c
5
5
  SHA512:
6
- metadata.gz: 630b938806894826b62ac90eace364299f940c50c117f0921c97ec084774e207dc23f0c87ca1b21942bcafdf1b7a3de19c6eee05b513a4ea7d010e6f633c9b07
7
- data.tar.gz: a0d9651b868af6775c299661928c16d648c26f9a61308620fe9575c6bbd159640a619179996d2bbc29bd9f8096e9e986bcde1e41bc47af98144a62ab772fb336
6
+ metadata.gz: 5ed7e26ed44a7e69d70791aee2c910a9ccc80c340bd26541a6f4679427c76a75b31e1ddd308816f20bb4ee3fcd3031d011679364cafb0c91d8b7256be659ab2c
7
+ data.tar.gz: bc4bcef987ba1287acc7ead7d6d4c596dd33e6b72f8b5d221352dd81e895be6c0d80f87cd12712f63168b86ab2a3fa916fc8959f15c30c72fe75062b55e6399f
@@ -1,59 +1,3 @@
1
1
  class Credible::SessionsController < ApplicationController
2
- before_action :set_session, only: [:show, :destroy]
3
-
4
- skip_before_action :authenticate!, only: [:new, :create, :fail]
5
-
6
- # skip_after_action :verify_authorized, only: [:fail]
7
- # TODO: Reevaluate authorization without Pundit
8
-
9
- # GET /sessions
10
- # GET /sessions.json
11
- def index
12
- end
13
-
14
- # GET /sessions/1
15
- # GET /sessions/1.json
16
- def show
17
- end
18
-
19
- # GET /sessions/new
20
- def new
21
- @session = ::Session.new
22
- end
23
-
24
- # POST /sessions
25
- # POST /sessions.json
26
- def create
27
- @session = ::Session.authenticate(session_params)
28
-
29
- if @session.save
30
- render :show, status: :created, location: @session
31
- else
32
- render json: @session.errors, status: :unprocessable_entity
33
- end
34
- end
35
-
36
- # DELETE /sessions/1
37
- # DELETE /sessions/1.json
38
- # DELETE /sessions/current
39
- # DELETE /sessions/current.json
40
- def destroy
41
- warden.logout
42
- @session.destroy
43
- head :no_content
44
- end
45
-
46
- def fail
47
- render json: {}, status: :unauthorized
48
- end
49
-
50
- private
51
- # Use callbacks to share common setup or constraints between actions.
52
- def set_session
53
- @session = current_session
54
- end
55
-
56
- def session_params
57
- params.require(:session).permit(:login, :password)
58
- end
2
+ include Credible::Controllers::SessionsController
59
3
  end
@@ -1,92 +1,3 @@
1
1
  class Credible::UsersController < ApplicationController
2
- before_action :set_user, only: [:show, :edit, :update, :destroy]
3
-
4
- skip_before_action :authenticate!, only: [:new, :create, :confirm]
5
-
6
- # TODO: Reevaluate authorization without Pundit
7
-
8
- # GET /users/1
9
- # GET /users/1.json
10
- def show
11
- end
12
-
13
- # GET /users/new
14
- def new
15
- @user = ::User.new
16
- end
17
-
18
- # POST /users
19
- # POST /users.json
20
- def create
21
- @user = ::User.new(user_params)
22
-
23
- if @user.save
24
- Credible::ConfirmationMailer.with(user: @user).confirmation_email.deliver_later
25
- @session = ::Session.create(user: @user)
26
- render :show, status: :created, location: @user
27
- else
28
- render json: @user.errors, status: :unprocessable_entity
29
- end
30
- end
31
-
32
- # GET /users/confirm/:confirmation_token
33
- # GET /users/confirm/:confirmation_token.json
34
- def confirm
35
- @user = ::User.find_by(email: params[:email])
36
-
37
- @user.confirm(params[:confirmation_token])
38
-
39
- if @user.save
40
- @session = current_user ? current_session : ::Session.create(user: @user)
41
- render :show, status: :created, location: @user
42
- else
43
- render json: @user.errors, status: :unprocessable_entity
44
- end
45
- end
46
-
47
- # POST /users/reset_password
48
- # POST /users/reset_password.json
49
- def reset_password
50
- @user = ::User.find_by(email: user_params[:email])
51
-
52
- @user.reset_password
53
-
54
- if @user.save
55
- Credible::ResetPasswordMailer.with(user: @user).reset_password_email.deliver_later
56
- render :show, status: :ok, location: @user
57
- else
58
- render json: @user.errors, status: :unprocessable_entity
59
- end
60
- end
61
-
62
- # GET /users/1/edit
63
- def edit
64
- end
65
-
66
- # PATCH/PUT /users/1
67
- # PATCH/PUT /users/1.json
68
- def update
69
- if @user.update(user_params)
70
- render :show, status: :ok, location: @user
71
- else
72
- render json: @user.errors, status: :unprocessable_entity
73
- end
74
- end
75
-
76
- # DELETE /users/1
77
- # DELETE /users/1.json
78
- def destroy
79
- @user.destroy
80
- head :no_content
81
- end
82
-
83
- private
84
- # Use callbacks to share common setup or constraints between actions.
85
- def set_user
86
- @user = current_user
87
- end
88
-
89
- def user_params
90
- params.require(:user).permit(:email, :password)
91
- end
2
+ include Credible::Controllers::UsersController
92
3
  end
data/lib/credible.rb CHANGED
@@ -4,6 +4,9 @@ require "credible/engine"
4
4
 
5
5
  require "credible/controller_concern"
6
6
 
7
+ require "credible/controllers/sessions_controller"
8
+ require "credible/controllers/users_controller"
9
+
7
10
  require "credible/user"
8
11
  require "credible/session"
9
12
 
@@ -0,0 +1,65 @@
1
+ module Credible
2
+ module Controllers
3
+ module SessionsController
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ before_action :set_session, only: [:show, :destroy]
8
+ skip_before_action :authenticate!, only: [:new, :create, :fail]
9
+ # skip_after_action :verify_authorized, only: [:fail]
10
+ # TODO: Reevaluate authorization without Pundit
11
+ end
12
+
13
+ # GET /sessions
14
+ # GET /sessions.json
15
+ def index
16
+ end
17
+
18
+ # GET /sessions/1
19
+ # GET /sessions/1.json
20
+ def show
21
+ end
22
+
23
+ # GET /sessions/new
24
+ def new
25
+ @session = ::Session.new
26
+ end
27
+
28
+ # POST /sessions
29
+ # POST /sessions.json
30
+ def create
31
+ @session = ::Session.authenticate(session_params)
32
+
33
+ if @session.save
34
+ render :show, status: :created, location: @session
35
+ else
36
+ render json: @session.errors, status: :unprocessable_entity
37
+ end
38
+ end
39
+
40
+ # DELETE /sessions/1
41
+ # DELETE /sessions/1.json
42
+ # DELETE /sessions/current
43
+ # DELETE /sessions/current.json
44
+ def destroy
45
+ warden.logout
46
+ @session.destroy
47
+ head :no_content
48
+ end
49
+
50
+ def fail
51
+ render json: {}, status: :unauthorized
52
+ end
53
+
54
+ private
55
+ # Use callbacks to share common setup or constraints between actions.
56
+ def set_session
57
+ @session = current_session
58
+ end
59
+
60
+ def session_params
61
+ params.require(:session).permit(:login, :password)
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,98 @@
1
+ module Credible
2
+ module Controllers
3
+ module UsersController
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ before_action :set_user, only: [:show, :edit, :update, :destroy]
8
+ skip_before_action :authenticate!, only: [:new, :create, :confirm]
9
+ # TODO: Reevaluate authorization without Pundit
10
+ end
11
+
12
+ # GET /users/1
13
+ # GET /users/1.json
14
+ def show
15
+ end
16
+
17
+ # GET /users/new
18
+ def new
19
+ @user = ::User.new
20
+ end
21
+
22
+ # POST /users
23
+ # POST /users.json
24
+ def create
25
+ @user = ::User.new(user_params)
26
+
27
+ if @user.save
28
+ Credible::ConfirmationMailer.with(user: @user).confirmation_email.deliver_later
29
+ @session = ::Session.create(user: @user)
30
+ render :show, status: :created, location: @user
31
+ else
32
+ render json: @user.errors, status: :unprocessable_entity
33
+ end
34
+ end
35
+
36
+ # GET /users/confirm/:confirmation_token
37
+ # GET /users/confirm/:confirmation_token.json
38
+ def confirm
39
+ @user = ::User.find_by(email: params[:email])
40
+
41
+ @user.confirm(params[:confirmation_token])
42
+
43
+ if @user.save
44
+ @session = current_user ? current_session : ::Session.create(user: @user)
45
+ render :show, status: :created, location: @user
46
+ else
47
+ render json: @user.errors, status: :unprocessable_entity
48
+ end
49
+ end
50
+
51
+ # POST /users/reset_password
52
+ # POST /users/reset_password.json
53
+ def reset_password
54
+ @user = ::User.find_by(email: user_params[:email])
55
+
56
+ @user.reset_password
57
+
58
+ if @user.save
59
+ Credible::ResetPasswordMailer.with(user: @user).reset_password_email.deliver_later
60
+ render :show, status: :ok, location: @user
61
+ else
62
+ render json: @user.errors, status: :unprocessable_entity
63
+ end
64
+ end
65
+
66
+ # GET /users/1/edit
67
+ def edit
68
+ end
69
+
70
+ # PATCH/PUT /users/1
71
+ # PATCH/PUT /users/1.json
72
+ def update
73
+ if @user.update(user_params)
74
+ render :show, status: :ok, location: @user
75
+ else
76
+ render json: @user.errors, status: :unprocessable_entity
77
+ end
78
+ end
79
+
80
+ # DELETE /users/1
81
+ # DELETE /users/1.json
82
+ def destroy
83
+ @user.destroy
84
+ head :no_content
85
+ end
86
+
87
+ private
88
+ # Use callbacks to share common setup or constraints between actions.
89
+ def set_user
90
+ @user = current_user
91
+ end
92
+
93
+ def user_params
94
+ params.require(:user).permit(:email, :password)
95
+ end
96
+ end
97
+ end
98
+ end
@@ -1,3 +1,3 @@
1
1
  module Credible
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom Bruce
@@ -123,7 +123,6 @@ extra_rdoc_files: []
123
123
  files:
124
124
  - README.md
125
125
  - Rakefile
126
- - app/controllers/credible/authentication_controller.rb
127
126
  - app/controllers/credible/sessions_controller.rb
128
127
  - app/controllers/credible/users_controller.rb
129
128
  - app/helpers/credible/application_helper.rb
@@ -147,6 +146,8 @@ files:
147
146
  - config/routes.rb
148
147
  - lib/credible.rb
149
148
  - lib/credible/controller_concern.rb
149
+ - lib/credible/controllers/sessions_controller.rb
150
+ - lib/credible/controllers/users_controller.rb
150
151
  - lib/credible/engine.rb
151
152
  - lib/credible/session.rb
152
153
  - lib/credible/user.rb
@@ -1,4 +0,0 @@
1
- class Credible::AuthenticationController < ApplicationController
2
- # TODO: Authentication module is now redundant inside Credible Engine.
3
- # Migrate out of namespace.
4
- end