trestle-auth 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 526a5bb317d5e7a4cc86bfc4bf3f8cc7738711b5
4
- data.tar.gz: 7e7ac41fbac4ab25372a076d22115d60ae5047cc
2
+ SHA256:
3
+ metadata.gz: 71e10f075c0aee1777d1823511187dfac4d50788006476a5f1a67f9f3555b352
4
+ data.tar.gz: e00d07780f77c7914eeaffea5574143064dfe5adc514d5c0580d7d794834cff6
5
5
  SHA512:
6
- metadata.gz: 7d992286cb24a3876ba4f60e46d3a43b95f936fdfa955479544083b5684755c3ed23a3e8d3cc296a5db81bf78b3e3b078413f2fc59b88a78721e2930968111e4
7
- data.tar.gz: eb1877b2b963f5351b1092e82f90a0de83efa1288adbf131fbc078391cf9fcbd1038642ebb450775d33bab07278c26ef6d16beabfe2c458ad04302c185b3201a
6
+ metadata.gz: 46d21d2099835f6d7f80a41f98b6983c1de41c2f4fbec486f7c069038f881a7097d6c78377c41e6a1c9b1a8d2d1e2e453c177de2cbfcfbf44f3e3f9410556b14
7
+ data.tar.gz: dd803d5a8055402aa4f1b9c6351429c8c4160052e3b2f902db7c830894b78ed9d416f434f0ea99c8e823b043943152465a49df4cd3023494539c149780539629
@@ -0,0 +1,4 @@
1
+ // This file is left as an extension point for user customization.
2
+ //
3
+ // It will be overridden by the similarly named file within
4
+ // the app/assets folder of the Rails application.
@@ -1,5 +1,6 @@
1
1
  // User-defined variables
2
2
  @import "trestle/support";
3
+ @import "auth/defaults";
3
4
 
4
5
  // 3rd party dependencies
5
6
  @import "trestle/bootstrap";
@@ -7,3 +8,6 @@
7
8
 
8
9
  @import "auth/layout";
9
10
  @import "auth/form";
11
+
12
+ // User customizations
13
+ @import "trestle/custom-auth";
@@ -0,0 +1,13 @@
1
+ $auth-bg: $theme-bg !default;
2
+
3
+ $auth-form-control-color: white !default;
4
+ $auth-form-control-placeholder: rgba(white, 0.5) !default;
5
+ $auth-form-control-bg: rgba(white, 0.1) !default;
6
+ $auth-form-control-border: 0 !default;
7
+
8
+ $auth-remember-me-color: rgba(white, 0.75) !default;
9
+ $auth-remember-me-bg: rgba(black, 0.075) !default;
10
+
11
+ $auth-login-btn-color: $btn-primary-color !default;
12
+ $auth-login-btn-border: $btn-primary-border !default;
13
+ $auth-login-btn-bg: $btn-primary-bg !default;
@@ -12,34 +12,15 @@ a {
12
12
  }
13
13
  }
14
14
 
15
- .remember-me {
16
- display: block;
17
- font-weight: normal;
18
- color: rgba(white, 0.75);
19
- background: rgba(black, 0.075);
20
- border-radius: 5px;
21
- padding: 10px 15px;
22
- font-size: 13px;
23
- cursor: pointer;
24
-
25
- input {
26
- margin-right: 10px;
27
- }
28
-
29
- &:hover {
30
- background: rgba(black, 0.1);
31
- }
32
- }
33
-
34
15
  .form-control, .input-group-addon {
35
- background: rgba(white, 0.1);
36
- border: none;
16
+ background: $auth-form-control-bg;
17
+ border: $auth-form-control-border;
37
18
  }
38
19
 
39
20
  .form-control {
40
21
  box-shadow: none;
41
22
 
42
- color: white;
23
+ color: $auth-form-control-color;
43
24
 
44
25
  height: auto;
45
26
  padding: 12px 5px;
@@ -53,11 +34,11 @@ a {
53
34
  }
54
35
 
55
36
  &::placeholder {
56
- color: rgba(white, 0.5);
37
+ color: $auth-form-control-placeholder;
57
38
  }
58
39
 
59
40
  &:-webkit-autofill {
60
- -webkit-text-fill-color: white;
41
+ -webkit-text-fill-color: $auth-form-control-color;
61
42
 
62
43
  &, &:hover, &:focus, &:active {
63
44
  transition: background-color 9999999s ease-in-out 0s;
@@ -73,6 +54,27 @@ a {
73
54
  }
74
55
  }
75
56
 
57
+ .remember-me {
58
+ display: block;
59
+ font-weight: normal;
60
+ color: $auth-remember-me-color;
61
+ background: $auth-remember-me-bg;
62
+ border-radius: 5px;
63
+ padding: 10px 15px;
64
+ font-size: 13px;
65
+ cursor: pointer;
66
+
67
+ input {
68
+ margin-right: 10px;
69
+ margin-top: 0;
70
+ vertical-align: middle;
71
+ }
72
+
73
+ &:hover {
74
+ background: opacify($auth-remember-me-bg, 0.05);
75
+ }
76
+ }
77
+
76
78
  .btn {
77
79
  box-shadow: rgba(black, 0.1) 0 0 2px;
78
80
  padding: 12px;
@@ -82,20 +84,24 @@ a {
82
84
  .btn-primary {
83
85
  outline: none;
84
86
 
87
+ color: $auth-login-btn-color;
88
+ background: $auth-login-btn-bg;
89
+ border: $auth-login-btn-border;
90
+
85
91
  &:hover {
86
- background-color: darken($btn-primary-bg, 2.5%);
87
- border-color: darken($btn-primary-border, 5%);
92
+ background-color: darken($auth-login-btn-bg, 2.5%);
93
+ border-color: darken($auth-login-btn-border, 5%);
88
94
  }
89
95
 
90
96
  &:focus, &:active {
91
- background-color: darken($btn-primary-bg, 5%);
92
- border-color: darken($btn-primary-border, 10%);
97
+ background-color: darken($auth-login-btn-bg, 5%);
98
+ border-color: darken($auth-login-btn-border, 10%);
93
99
  }
94
100
 
95
101
  &:active:focus {
96
102
  outline: none !important;
97
- background-color: darken($btn-primary-bg, 10%);
98
- border-color: darken($btn-primary-border, 15%);
103
+ background-color: darken($auth-login-btn-bg, 10%);
104
+ border-color: darken($auth-login-btn-border, 15%);
99
105
  }
100
106
  }
101
107
 
@@ -9,7 +9,7 @@ body {
9
9
  overflow: hidden;
10
10
 
11
11
  color: white;
12
- background: $theme-bg;
12
+ background: $auth-bg;
13
13
 
14
14
  display: flex;
15
15
  }
data/config/locale/en.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  en:
2
2
  admin:
3
3
  auth:
4
- my_account: My Account
5
- login: Login
6
- logout: Logout
7
- error: Incorrect login details.
8
- remember_me: Remember me
4
+ my_account: "My Account"
5
+ login: "Login"
6
+ logout: "Logout"
7
+ error: "Incorrect login details."
8
+ remember_me: "Remember me"
@@ -0,0 +1,8 @@
1
+ pl:
2
+ admin:
3
+ auth:
4
+ my_account: "Moje konto"
5
+ login: "Zaloguj się"
6
+ logout: "Wyloguj się"
7
+ error: "Nieprawidłowe dane logowania."
8
+ remember_me: "Zapamiętaj mnie"
@@ -0,0 +1,8 @@
1
+ pt-BR:
2
+ admin:
3
+ auth:
4
+ my_account: "Minha Conta"
5
+ login: "Entrar"
6
+ logout: "Sair"
7
+ error: "Email ou Senha incorretos."
8
+ remember_me: "Lembrar-me"
@@ -51,6 +51,13 @@ module Trestle
51
51
  # user.locale if user.respond_to?(:locale)
52
52
  # }
53
53
 
54
+ # Customize the method for determining the user's time zone.
55
+ # Defaults to user.time_zone (if the method is defined).
56
+ #
57
+ # config.auth.time_zone = ->(user) {
58
+ # user.time_zone if user.respond_to?(:time_zone)
59
+ # }
60
+
54
61
  # Enable or disable remember me functionality. Defaults to true.
55
62
  #
56
63
  # config.auth.remember.enabled = false
@@ -65,6 +72,12 @@ module Trestle
65
72
  # User.authenticate_with_remember_token(token)
66
73
  # }
67
74
 
75
+ # Customize the method for finding a user given an ID from the session.
76
+ #
77
+ # config.auth.remember.find_user = ->(id) {
78
+ # User.find_by(id: id)
79
+ # }
80
+
68
81
  # Customize the method for remembering a user.
69
82
  #
70
83
  # config.auth.remember.remember_me, ->(user) { user.remember_me! }
data/lib/trestle/auth.rb CHANGED
@@ -7,6 +7,7 @@ module Trestle
7
7
  extend ActiveSupport::Autoload
8
8
 
9
9
  autoload :Configuration
10
+ autoload :Constraint
10
11
  autoload :ControllerMethods
11
12
  autoload :ModelMethods
12
13
  autoload :NullUser
@@ -34,6 +34,10 @@ module Trestle
34
34
  user.locale if user.respond_to?(:locale)
35
35
  }
36
36
 
37
+ option :time_zone, ->(user) {
38
+ user.time_zone if user.respond_to?(:time_zone)
39
+ }
40
+
37
41
  option :remember, Rememberable.new
38
42
  end
39
43
  end
@@ -0,0 +1,9 @@
1
+ module Trestle
2
+ module Auth
3
+ class Constraint
4
+ def matches?(request)
5
+ Trestle.config.auth.find_user(request.session[:trestle_user]) if request.session[:trestle_user]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -7,7 +7,9 @@ module Trestle
7
7
  helper_method :current_user, :logged_in?
8
8
 
9
9
  before_action :require_authenticated_user
10
- around_action :set_locale
10
+
11
+ around_action :set_locale, if: :logged_in?
12
+ around_action :set_time_zone, if: :logged_in?
11
13
  end
12
14
 
13
15
  protected
@@ -69,10 +71,11 @@ module Trestle
69
71
  end
70
72
 
71
73
  def set_locale
72
- self.locale = Trestle.config.auth.locale(current_user) || I18n.default_locale if logged_in?
73
- yield
74
- ensure
75
- self.locale = I18n.default_locale
74
+ I18n.with_locale(Trestle.config.auth.locale(current_user) || I18n.default_locale) { yield }
75
+ end
76
+
77
+ def set_time_zone
78
+ Time.use_zone(Trestle.config.auth.time_zone(current_user) || Rails.application.config.time_zone) { yield }
76
79
  end
77
80
  end
78
81
  end
@@ -1,5 +1,5 @@
1
1
  module Trestle
2
2
  module Auth
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
data/trestle-auth.gemspec CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ["sam@sampohlenz.com"]
12
12
 
13
13
  spec.summary = "Authentication plugin for the Trestle admin framework"
14
- spec.description = "Authentication plugin for the Trestle admin framework."
15
14
  spec.homepage = "https://www.trestle.io"
16
15
  spec.license = "LGPL-3.0"
17
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trestle-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pohlenz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-24 00:00:00.000000000 Z
11
+ date: 2018-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trestle
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
- description: Authentication plugin for the Trestle admin framework.
83
+ description:
84
84
  email:
85
85
  - sam@sampohlenz.com
86
86
  executables: []
@@ -95,7 +95,9 @@ files:
95
95
  - README.md
96
96
  - Rakefile
97
97
  - app/assets/javascripts/trestle/auth.js
98
+ - app/assets/stylesheets/trestle/_custom-auth.scss
98
99
  - app/assets/stylesheets/trestle/auth.scss
100
+ - app/assets/stylesheets/trestle/auth/_defaults.scss
99
101
  - app/assets/stylesheets/trestle/auth/_form.scss
100
102
  - app/assets/stylesheets/trestle/auth/_layout.scss
101
103
  - app/assets/stylesheets/trestle/auth/userbox.scss
@@ -106,6 +108,8 @@ files:
106
108
  - app/views/trestle/auth/sessions/new.html.erb
107
109
  - config/initializers/trestle.rb
108
110
  - config/locale/en.yml
111
+ - config/locale/pl.yml
112
+ - config/locale/pt-BR.yml
109
113
  - config/routes.rb
110
114
  - lib/generators/trestle/auth/admin/admin_generator.rb
111
115
  - lib/generators/trestle/auth/admin/templates/admin.rb.erb
@@ -114,6 +118,7 @@ files:
114
118
  - lib/trestle/auth.rb
115
119
  - lib/trestle/auth/configuration.rb
116
120
  - lib/trestle/auth/configuration/rememberable.rb
121
+ - lib/trestle/auth/constraint.rb
117
122
  - lib/trestle/auth/controller_methods.rb
118
123
  - lib/trestle/auth/engine.rb
119
124
  - lib/trestle/auth/model_methods.rb
@@ -141,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
146
  version: '0'
142
147
  requirements: []
143
148
  rubyforge_project:
144
- rubygems_version: 2.6.12
149
+ rubygems_version: 2.7.3
145
150
  signing_key:
146
151
  specification_version: 4
147
152
  summary: Authentication plugin for the Trestle admin framework