tramway-auth 1.1.0.1 → 1.1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -5
- data/app/controllers/concerns/tramway/auth_management.rb +33 -0
- data/app/controllers/tramway/auth/application_controller.rb +2 -0
- data/app/controllers/tramway/auth/web/application_controller.rb +4 -2
- data/app/controllers/tramway/auth/web/sessions_controller.rb +2 -0
- data/app/forms/tramway/auth/session_form.rb +3 -1
- data/app/helpers/tramway/auth/application_helper.rb +2 -0
- data/app/jobs/tramway/auth/application_job.rb +2 -0
- data/app/mailers/tramway/auth/application_mailer.rb +2 -0
- data/app/models/tramway/auth/application_record.rb +2 -0
- data/config/routes.rb +3 -1
- data/lib/tasks/tramway/auth_tasks.rake +2 -0
- data/lib/tramway/auth.rb +6 -8
- data/lib/tramway/auth/engine.rb +2 -0
- data/lib/tramway/auth/version.rb +3 -1
- metadata +3 -3
- data/app/controllers/concerns/auth_management.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17e985facc791296ef2dabb8de8ea72f7ede24e1676b86207fcc47537dbfb4d4
|
4
|
+
data.tar.gz: fed766e1558ac7839ceb43e042dafff2a4fe71ab9f2de3d874e10392032caa80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b18bec956230a0783fb3a8c6104a8a87c2bc1bcdd9dd522af5021095bb9e63f37d38cacda45855faebb647fafc4e57fc40dd1250ad12691a0bba9487a382b9f
|
7
|
+
data.tar.gz: d9c12efdcd5e423365a7e56e7b0504dda55c32cdbd7d4060a984de5c6665f63c00abc6c6447a75b9047f234fde163e4086af3af940d94352c8c9b4908a32f392
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
begin
|
2
4
|
require 'bundler/setup'
|
3
5
|
rescue LoadError
|
@@ -14,14 +16,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
16
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
17
|
end
|
16
18
|
|
17
|
-
APP_RAKEFILE = File.expand_path(
|
19
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
18
20
|
load 'rails/tasks/engine.rake'
|
19
21
|
|
20
|
-
|
21
22
|
load 'rails/tasks/statistics.rake'
|
22
23
|
|
23
|
-
|
24
|
-
|
25
24
|
require 'bundler/gem_tasks'
|
26
25
|
|
27
26
|
require 'rake/testtask'
|
@@ -32,5 +31,4 @@ Rake::TestTask.new(:test) do |t|
|
|
32
31
|
t.verbose = false
|
33
32
|
end
|
34
33
|
|
35
|
-
|
36
34
|
task default: :test
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tramway
|
4
|
+
module AuthManagement
|
5
|
+
def sign_in(user)
|
6
|
+
session[:user_id] = user.id
|
7
|
+
end
|
8
|
+
|
9
|
+
def sign_out
|
10
|
+
session[:user_id] = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def signed_in?
|
14
|
+
current_user
|
15
|
+
end
|
16
|
+
|
17
|
+
def authenticate_user!
|
18
|
+
redirect_to new_session_path unless signed_in?
|
19
|
+
end
|
20
|
+
|
21
|
+
def authenticate_admin!
|
22
|
+
if signed_in?
|
23
|
+
redirect_to ::Tramway::Auth.root_path if !current_user.admin? && request.env['PATH_INFO'] != ::Tramway::Auth.root_path
|
24
|
+
else
|
25
|
+
redirect_to '/auth/session/new'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def current_user
|
30
|
+
@_current_user ||= ::Tramway::User::User.find_by id: session[:user_id]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'tramway/auth/application_controller'
|
2
4
|
|
3
5
|
class Tramway::Auth::Web::ApplicationController < ::Tramway::Auth::ApplicationController
|
4
|
-
include AuthManagement
|
6
|
+
include Tramway::AuthManagement
|
5
7
|
end
|
data/config/routes.rb
CHANGED
data/lib/tramway/auth.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tramway/auth/engine'
|
2
4
|
|
3
5
|
module Tramway
|
4
6
|
module Auth
|
@@ -15,22 +17,18 @@ module Tramway
|
|
15
17
|
@authenticable_classes << value
|
16
18
|
end
|
17
19
|
end
|
18
|
-
|
20
|
+
|
19
21
|
def root
|
20
22
|
File.dirname __dir__
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
@layout_path = path
|
25
|
-
end
|
25
|
+
attr_writer :layout_path
|
26
26
|
|
27
27
|
def layout_path
|
28
28
|
@layout_path ||= 'tramway/user/application'
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
@root_path = path
|
33
|
-
end
|
31
|
+
attr_writer :root_path
|
34
32
|
|
35
33
|
def root_path
|
36
34
|
@root_path || '/'
|
data/lib/tramway/auth/engine.rb
CHANGED
data/lib/tramway/auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.
|
4
|
+
version: 1.1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rails engine for auth
|
14
14
|
email:
|
@@ -23,7 +23,7 @@ files:
|
|
23
23
|
- app/assets/config/tramway_auth_manifest.js
|
24
24
|
- app/assets/javascripts/tramway/auth/application.js
|
25
25
|
- app/assets/stylesheets/tramway/auth/application.css
|
26
|
-
- app/controllers/concerns/auth_management.rb
|
26
|
+
- app/controllers/concerns/tramway/auth_management.rb
|
27
27
|
- app/controllers/tramway/auth/application_controller.rb
|
28
28
|
- app/controllers/tramway/auth/web/application_controller.rb
|
29
29
|
- app/controllers/tramway/auth/web/sessions_controller.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module AuthManagement
|
2
|
-
def sign_in(user)
|
3
|
-
session[:user_id] = user.id
|
4
|
-
end
|
5
|
-
|
6
|
-
def sign_out
|
7
|
-
session[:user_id] = nil
|
8
|
-
end
|
9
|
-
|
10
|
-
def signed_in?
|
11
|
-
current_user
|
12
|
-
end
|
13
|
-
|
14
|
-
def authenticate_user!
|
15
|
-
redirect_to new_session_path unless signed_in?
|
16
|
-
end
|
17
|
-
|
18
|
-
def authenticate_admin!
|
19
|
-
if signed_in?
|
20
|
-
redirect_to ::Tramway::Auth.root_path if !current_user.admin? && request.env['PATH_INFO'] != ::Tramway::Auth.root_path
|
21
|
-
else
|
22
|
-
redirect_to '/auth/session/new'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def current_user
|
27
|
-
@_current_user ||= ::Tramway::User::User.find_by id: session[:user_id]
|
28
|
-
end
|
29
|
-
end
|