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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64ccdc8466378b0002ace0e0f152df79325bde856c62e382c32c427749065e4c
4
- data.tar.gz: 70b653b4140905942200edbbab6236d9d28229167906a6a601cf0926c139d556
3
+ metadata.gz: 17e985facc791296ef2dabb8de8ea72f7ede24e1676b86207fcc47537dbfb4d4
4
+ data.tar.gz: fed766e1558ac7839ceb43e042dafff2a4fe71ab9f2de3d874e10392032caa80
5
5
  SHA512:
6
- metadata.gz: 47d2136bf2032cdced3e5f838ea63716bd935cad388562218a648369e3429dd318e46c54a6c743d00b1acba376772889645cce0242e5c6f89e15adb857d6ba44
7
- data.tar.gz: c3cef2df26ed1220b098096426dc8d9ecece3e4a59c70dbc342c3641595261936aa82574b22cfcb3719ca0506279d0b0a37e128600075294ed591bbb1ed0fb66
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("../test/dummy/Rakefile", __FILE__)
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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Auth
3
5
  class ApplicationController < ActionController::Base
@@ -1,5 +1,7 @@
1
- require_dependency "tramway/auth/application_controller"
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway::Auth
2
4
  module Web
3
5
  class SessionsController < ::Tramway::Auth::Web::ApplicationController
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway::Auth
2
4
  class SessionForm < ::Tramway::Core::ApplicationForm
3
5
  properties :email
4
- attr_accessor :password
6
+ attr_accessor :password
5
7
 
6
8
  def model_name
7
9
  User
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Auth
3
5
  module ApplicationHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Auth
3
5
  class ApplicationJob < ActiveJob::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Auth
3
5
  class ApplicationMailer < ActionMailer::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Auth
3
5
  class ApplicationRecord < ActiveRecord::Base
data/config/routes.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Tramway::Auth::Engine.routes.draw do
2
4
  scope module: :web do
3
- resource :session, only: [ :new, :create, :destroy ]
5
+ resource :session, only: %i[new create destroy]
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # desc "Explaining what the task does"
2
4
  # task :tramway_auth do
3
5
  # # Task goes here
data/lib/tramway/auth.rb CHANGED
@@ -1,4 +1,6 @@
1
- require "tramway/auth/engine"
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
- def layout_path=(path)
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
- def root_path=(path)
32
- @root_path = path
33
- end
31
+ attr_writer :root_path
34
32
 
35
33
  def root_path
36
34
  @root_path || '/'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Auth
3
5
  class Engine < ::Rails::Engine
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Auth
3
- VERSION = '1.1.0.1'
5
+ VERSION = '1.1.0.2'
4
6
  end
5
7
  end
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.1
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-09-09 00:00:00.000000000 Z
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