trestle-auth 0.2.5 → 0.3.0

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.browserslistrc +2 -0
  3. data/.gitignore +1 -0
  4. data/app/assets/bundle/trestle/auth/bundle.css +1 -0
  5. data/app/assets/bundle/trestle/auth/userbox.css +1 -0
  6. data/app/assets/stylesheets/trestle/_custom-auth.css +6 -0
  7. data/app/assets/stylesheets/trestle/auth.css +2 -0
  8. data/app/helpers/trestle/auth/title_helper.rb +3 -1
  9. data/app/views/layouts/trestle/auth.html.erb +11 -8
  10. data/app/views/trestle/auth/_userbox.html.erb +3 -4
  11. data/app/views/trestle/auth/sessions/new.html.erb +17 -9
  12. data/config/{locale → locales}/en.yml +0 -0
  13. data/config/locales/es.yml +8 -0
  14. data/config/{locale → locales}/pl.yml +0 -0
  15. data/config/{locale → locales}/pt-BR.yml +0 -0
  16. data/config/{locale → locales}/zh-CN.yml +0 -0
  17. data/frontend/_form.scss +79 -0
  18. data/frontend/_layout.scss +35 -0
  19. data/{app/assets/stylesheets/trestle/auth/_defaults.scss → frontend/_variables.scss} +2 -6
  20. data/frontend/index.scss +5 -0
  21. data/{app/assets/stylesheets/trestle/auth → frontend}/userbox.scss +10 -12
  22. data/lib/generators/trestle/auth/install/install_generator.rb +6 -0
  23. data/lib/trestle/auth/configuration.rb +2 -0
  24. data/lib/trestle/auth/engine.rb +1 -1
  25. data/lib/trestle/auth/version.rb +1 -1
  26. data/package.json +29 -0
  27. data/trestle-auth.gemspec +2 -2
  28. data/webpack.config.js +49 -0
  29. data/yarn.lock +4957 -0
  30. metadata +23 -17
  31. data/app/assets/javascripts/trestle/auth.js +0 -0
  32. data/app/assets/stylesheets/trestle/_custom-auth.scss +0 -4
  33. data/app/assets/stylesheets/trestle/auth.scss +0 -13
  34. data/app/assets/stylesheets/trestle/auth/_form.scss +0 -138
  35. data/app/assets/stylesheets/trestle/auth/_layout.scss +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ef9ad52449a79a688c9ee2a6e7b86c35179b4c0bad12390f69cb31cf25704ff
4
- data.tar.gz: 30f3172c89781a4baa176f1dffa233efbb1060a7cf5171aa93339b7aa27d1d3f
3
+ metadata.gz: c66ad14a57d22f21b9e9b170a48a505060704b557c0abde4e56526f1b7d95561
4
+ data.tar.gz: b8d449820f15f9923724d58650f965715cf420073d52d52d4353e20f6de14068
5
5
  SHA512:
6
- metadata.gz: c51b04bb59d56bf4e65f268944fb1b1f0e92001ad83115f630a24381bc70f7474491456126bfffad1372612150d75481dd98bb46cbc2e200116efb4cc1983c89
7
- data.tar.gz: f5dfe2f6cf6298d8b8ff39be723498951d40a77f53671e4845a85c23c7bfddc09f27ff21fdf06e583f33e8254d9f9c3e37faa33b873e2af732e91be0df776b06
6
+ metadata.gz: d58fe42ceab549559ffa679ef6e028695c27d815e4958278300a0de0ff943ff0f8480519e3bfd1cd59fac6e3763afdfa3829dc31c8d6475018f7ef8c21d4e738
7
+ data.tar.gz: af0149b4c92cad0b37bf42f82369507a2d3a57c46a8ed116ef2781965a7b837688c7a7fd0c50fd0087493b39b74266d0ba062a2e25c700747c47b4730591a835
@@ -0,0 +1,2 @@
1
+ > 0.25%
2
+
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /node_modules/
@@ -0,0 +1 @@
1
+ .auth-body{display:-webkit-box;display:flex;color:#fff}.auth-body .container{margin:auto;width:320px}.auth-header{text-align:center;margin-bottom:20px}.auth-header h1{display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;font-size:1.75rem;font-weight:500;text-shadow:rgba(0,0,0,.5) 0 1px 1px;padding:.75rem 1rem}.auth-header img{max-width:80%;max-height:100%}.auth-header span{margin-left:10px}.login-form .form-control,.login-form .input-group-text{background:hsla(0,0%,100%,.1);border:0}.login-form .form-control{color:#fff;font-size:1.1rem;padding:1.75rem .75rem}.login-form .form-control:focus{outline-color:transparent;outline-style:none;box-shadow:none}.login-form .form-control::-webkit-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control::-moz-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control:-ms-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control::-ms-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control::placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control:-webkit-autofill{-webkit-text-fill-color:#fff}.login-form .form-control:-webkit-autofill,.login-form .form-control:-webkit-autofill:active,.login-form .form-control:-webkit-autofill:focus,.login-form .form-control:-webkit-autofill:hover{-webkit-transition:background-color 9999999s ease-in-out 0s;transition:background-color 9999999s ease-in-out 0s}.login-form .input-group-prepend{margin-right:0}.login-form .input-group-text{color:hsla(0,0%,100%,.5);padding:.375rem .25rem .375rem 1rem}.login-form .btn-primary{box-shadow:0 0 2px rgba(0,0,0,.1);padding-top:.75rem;padding-bottom:.75rem}.login-form .alert-danger{background-color:rgba(222,116,113,.75)}.login-form .remember-me{font-size:.95rem;line-height:1.5;padding-left:0}.login-form .remember-me .custom-control-label{display:block;cursor:pointer;background:rgba(0,0,0,.075);color:hsla(0,0%,100%,.75);border-radius:.25rem;padding:.75em 1.5em .75em 3.25em}.login-form .remember-me .custom-control-label:hover{background:rgba(0,0,0,.125)}.login-form .remember-me .custom-control-label:after,.login-form .remember-me .custom-control-label:before{top:.925em;left:1.1em}
@@ -0,0 +1 @@
1
+ .userbox{-webkit-box-ordinal-group:100;order:99;padding:2px 0}.userbox>a{color:#333;display:block;padding:2px 0;font-weight:400;line-height:40px}.userbox>a:focus,.userbox>a:hover{text-decoration:none}.userbox .avatar{vertical-align:top;margin-left:6px}.userbox .dropdown-toggle:after{vertical-align:middle}@media (max-width:767.98px){.userbox{display:block;position:relative;z-index:5}.userbox .name{display:none}.userbox .avatar{border:1px solid hsla(0,0%,100%,.25)}}
@@ -0,0 +1,6 @@
1
+ /*
2
+ * This file is left as an extension point for user customization.
3
+ *
4
+ * It will be overridden by the similarly named file within
5
+ * the app/assets folder of the Rails application.
6
+ */
@@ -0,0 +1,2 @@
1
+ //= require trestle/auth/bundle
2
+ //= require trestle/_custom-auth
@@ -2,7 +2,9 @@ module Trestle
2
2
  module Auth
3
3
  module TitleHelper
4
4
  def trestle_auth_title
5
- if Trestle.config.site_logo
5
+ if Trestle.config.auth.logo
6
+ image_tag(Trestle.config.auth.logo)
7
+ elsif Trestle.config.site_logo
6
8
  image_tag(Trestle.config.site_logo)
7
9
  elsif Trestle.config.site_logo_small
8
10
  safe_join([
@@ -5,24 +5,27 @@
5
5
  <meta content='width=device-width, initial-scale=1' name='viewport'>
6
6
  <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
7
7
 
8
- <meta content='no-cache' name='turbolinks-cache-control'>
8
+ <% if Trestle.config.turbolinks %>
9
+ <meta content='no-cache' name='turbolinks-cache-control'>
10
+ <% end %>
9
11
 
10
12
  <%= csrf_meta_tags %>
11
13
 
12
14
  <title><%= Trestle.config.site_title %></title>
13
15
 
16
+ <%= stylesheet_link_tag "trestle/admin", 'data-turbolinks-track': 'reload' %>
17
+ <%= stylesheet_link_tag "trestle/theme", 'data-turbolinks-track': 'reload' if Trestle.config.theme %>
18
+ <%= stylesheet_link_tag "trestle/custom", 'data-turbolinks-track': 'reload' %>
19
+
14
20
  <%= stylesheet_link_tag "trestle/auth", 'data-turbolinks-track': 'reload' %>
15
21
 
16
- <%= javascript_include_tag "turbolinks" if defined?(Turbolinks) %>
17
- <%= javascript_include_tag "trestle/auth", 'data-turbolinks-track': 'reload' %>
22
+ <%= javascript_include_tag "turbolinks" if Trestle.config.turbolinks %>
23
+
24
+ <%= hook "auth.head" %>
18
25
  </head>
19
26
 
20
- <body>
27
+ <body class="auth-body theme-bg-dark">
21
28
  <main class="container">
22
- <header class="auth-header">
23
- <h1><%= trestle_auth_title %></h1>
24
- </header>
25
-
26
29
  <%= yield %>
27
30
  </main>
28
31
  </body>
@@ -1,8 +1,7 @@
1
- <div class="userbox pull-right dropdown">
2
- <%= link_to "#", class: 'dropdown-toggle', data: { toggle: 'dropdown' } do %>
3
- <span class="name">
1
+ <div class="userbox dropdown">
2
+ <%= link_to "#", data: { toggle: 'dropdown' } do %>
3
+ <span class="name dropdown-toggle">
4
4
  <%= format_user_name(current_user) %>
5
- <span class="caret"></span>
6
5
  </span>
7
6
 
8
7
  <%= avatar_for(current_user) %>
@@ -1,22 +1,30 @@
1
1
  <%= form_tag login_path, class: "login-form" do %>
2
- <%= hook("auth.login.heading") %>
2
+ <header class="auth-header">
3
+ <%= hook("auth.login.heading") do %>
4
+ <h1><%= trestle_auth_title %></h1>
5
+ <% end %>
6
+ </header>
3
7
 
4
8
  <% if flash[:error] -%>
5
- <div class="alert alert-danger">
9
+ <div class="alert alert-danger error-bg">
6
10
  <p><%= flash[:error] %></p>
7
11
  </div>
8
12
  <% end -%>
9
13
 
10
14
  <div class="form-group">
11
15
  <div class="input-group">
12
- <span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
16
+ <div class="input-group-prepend">
17
+ <span class="input-group-text"><i class="fa fa-user fa-fw"></i></span>
18
+ </div>
13
19
  <%= text_field_tag Trestle.config.auth.authenticate_with, "", placeholder: Trestle.config.auth.authenticate_with.to_s.humanize, class: "form-control" %>
14
20
  </div>
15
21
  </div>
16
22
 
17
23
  <div class="form-group">
18
24
  <div class="input-group">
19
- <span class="input-group-addon"><i class="fa fa-lock fa-fw"></i></span>
25
+ <div class="input-group-prepend">
26
+ <span class="input-group-text"><i class="fa fa-lock fa-fw"></i></span>
27
+ </div>
20
28
  <%= password_field_tag :password, "", placeholder: "Password", class: "form-control" %>
21
29
  </div>
22
30
  </div>
@@ -25,14 +33,14 @@
25
33
 
26
34
  <% if Trestle.config.auth.remember.enabled %>
27
35
  <div class="form-group">
28
- <label class="remember-me">
29
- <%= check_box_tag :remember_me %>
30
- <%= t("admin.auth.remember_me", default: "Remember me") %>
31
- </label>
36
+ <div class="custom-control custom-checkbox remember-me">
37
+ <%= check_box_tag :remember_me, "1", false, class: "custom-control-input" %>
38
+ <%= label_tag :remember_me, t("admin.auth.remember_me", default: "Remember me"), class: "custom-control-label" %>
39
+ </div>
32
40
  </div>
33
41
  <% end %>
34
42
 
35
43
  <div class="form-group">
36
- <%= submit_tag t("admin.auth.login", default: "Login"), class: "btn btn-primary btn-block" %>
44
+ <%= submit_tag t("admin.auth.login", default: "Login"), class: "btn btn-primary btn-block btn-lg" %>
37
45
  </div>
38
46
  <% end %>
File without changes
@@ -0,0 +1,8 @@
1
+ es:
2
+ admin:
3
+ auth:
4
+ my_account: "Mi Conta"
5
+ login: "Inicio de sesión"
6
+ logout: "Sair"
7
+ error: "Email o contraseña incorrectos."
8
+ remember_me: "Recuérdame"
File without changes
File without changes
File without changes
@@ -0,0 +1,79 @@
1
+ .login-form {
2
+ .form-control, .input-group-text {
3
+ background: $auth-form-control-bg;
4
+ border: $auth-form-control-border;
5
+ }
6
+
7
+ .form-control {
8
+ color: $auth-form-control-color;
9
+ font-size: 1.1rem;
10
+
11
+ padding: 1.75rem 0.75rem;
12
+
13
+ &:focus {
14
+ outline-color: transparent;
15
+ outline-style: none;
16
+ box-shadow: none;
17
+ }
18
+
19
+ &::placeholder {
20
+ color: $auth-form-control-placeholder;
21
+ }
22
+
23
+ &:-webkit-autofill {
24
+ -webkit-text-fill-color: $auth-form-control-color;
25
+
26
+ &, &:hover, &:focus, &:active {
27
+ transition: background-color 9999999s ease-in-out 0s;
28
+ }
29
+ }
30
+ }
31
+
32
+ .input-group-prepend {
33
+ margin-right: 0;
34
+ }
35
+
36
+ .input-group-text {
37
+ color: $auth-form-control-icon-color;
38
+ padding: 0.375rem 0.25rem 0.375rem 1rem;
39
+ }
40
+
41
+ .btn-primary {
42
+ box-shadow: rgba(black, 0.1) 0 0 2px;
43
+
44
+ padding-top: 0.75rem;
45
+ padding-bottom: 0.75rem;
46
+ }
47
+
48
+ .alert-danger {
49
+ background-color: rgba($alert-danger-bg, 0.75);
50
+ }
51
+
52
+ .remember-me {
53
+ font-size: 0.95rem;
54
+ line-height: 1.5;
55
+
56
+ padding-left: 0;
57
+
58
+ .custom-control-label {
59
+ display: block;
60
+ cursor: pointer;
61
+
62
+ background: $auth-remember-me-bg;
63
+ color: $auth-remember-me-color;
64
+
65
+ border-radius: $border-radius;
66
+ padding: 0.75em 1.5em 0.75em 3.25em;
67
+
68
+ &:hover {
69
+ background: opacify($auth-remember-me-bg, 0.05);
70
+ }
71
+
72
+ &::before,
73
+ &::after {
74
+ top: 0.175em + 0.75em;
75
+ left: 1.1em;
76
+ }
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,35 @@
1
+ .auth-body {
2
+ display: flex;
3
+ color: white;
4
+
5
+ .container {
6
+ margin: auto;
7
+ width: 320px;
8
+ }
9
+ }
10
+
11
+ .auth-header {
12
+ text-align: center;
13
+ margin-bottom: 20px;
14
+
15
+ h1 {
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+
20
+ font-size: 1.75rem;
21
+ font-weight: 500;
22
+ text-shadow: rgba(black, 0.5) 0 1px 1px;
23
+
24
+ padding: 0.75rem 1rem;
25
+ }
26
+
27
+ img {
28
+ max-width: 80%;
29
+ max-height: 100%;
30
+ }
31
+
32
+ span {
33
+ margin-left: 10px;
34
+ }
35
+ }
@@ -1,13 +1,9 @@
1
- $auth-bg: $theme-bg !default;
2
-
3
1
  $auth-form-control-color: white !default;
4
2
  $auth-form-control-placeholder: rgba(white, 0.5) !default;
5
3
  $auth-form-control-bg: rgba(white, 0.1) !default;
6
4
  $auth-form-control-border: 0 !default;
7
5
 
6
+ $auth-form-control-icon-color: rgba(white, 0.5) !default;
7
+
8
8
  $auth-remember-me-color: rgba(white, 0.75) !default;
9
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;
@@ -0,0 +1,5 @@
1
+ @import "~trestle/frontend/css/support";
2
+
3
+ @import "variables";
4
+ @import "layout";
5
+ @import "form";
@@ -1,16 +1,15 @@
1
- @import "trestle/support";
1
+ @import "~trestle/frontend/css/support";
2
2
 
3
3
  .userbox {
4
- margin-top: 2px;
5
- margin-bottom: 2px;
4
+ order: 99;
5
+ padding: 2px 0;
6
6
 
7
7
  > a {
8
- color: $text-color;
8
+ color: $body-color;
9
9
 
10
10
  display: block;
11
11
  padding: 2px 0;
12
12
 
13
- font-size: 14px;
14
13
  font-weight: normal;
15
14
  line-height: 40px;
16
15
 
@@ -24,20 +23,19 @@
24
23
  margin-left: 6px;
25
24
  }
26
25
 
27
- .name {
28
- color: $text-color;
26
+ .dropdown-toggle {
27
+ &::after {
28
+ vertical-align: middle;
29
+ }
29
30
  }
30
31
  }
31
32
 
32
- @include mobile {
33
+ @include media-breakpoint-down(sm) {
33
34
  .userbox {
35
+ display: block;
34
36
  position: relative;
35
37
  z-index: 5;
36
38
 
37
- > a, .name {
38
- color: white;
39
- }
40
-
41
39
  .name {
42
40
  display: none;
43
41
  }
@@ -97,6 +97,12 @@ module Trestle
97
97
  #
98
98
  # config.auth.redirect_on_logout = -> { "/" }
99
99
 
100
+ # Specify the logo used on the login form.
101
+ # If not specified, will fall back to config.site_logo,
102
+ # config.site_logo_small or config.site_title.
103
+ #
104
+ # config.auth.logo = "auth-logo.png"
105
+
100
106
  # Enable or disable remember me functionality. Defaults to true.
101
107
  #
102
108
  # config.auth.remember.enabled = false
@@ -49,6 +49,8 @@ module Trestle
49
49
  option :redirect_on_login, -> { Trestle.config.path }, evaluate: false
50
50
  option :redirect_on_logout, -> { login_url }, evaluate: false
51
51
 
52
+ option :logo
53
+
52
54
  option :remember, Rememberable.new
53
55
  end
54
56
  end
@@ -1,7 +1,7 @@
1
1
  module Trestle
2
2
  module Auth
3
3
  class Engine < ::Rails::Engine
4
- config.assets.precompile << "trestle/auth.css" << "trestle/auth.js" << "trestle/auth/userbox.scss"
4
+ config.assets.precompile << "trestle/auth.css" << "trestle/auth/userbox.css"
5
5
 
6
6
  config.before_initialize do
7
7
  Trestle::Engine.paths["app/helpers"].concat(paths["app/helpers"].existent)
@@ -1,5 +1,5 @@
1
1
  module Trestle
2
2
  module Auth
3
- VERSION = "0.2.5"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "trestle-auth",
3
+ "version": "0.3.0",
4
+ "description": "Authentication plugin for the Trestle admin framework",
5
+ "repository": "https://github.com/TrestleAdmin/trestle-auth.git",
6
+ "author": "Sam Pohlenz <sam@sampohlenz.com>",
7
+ "license": "LGPL-3.0",
8
+ "private": true,
9
+ "scripts": {
10
+ "dev": "webpack --mode development",
11
+ "build": "webpack --mode production",
12
+ "watch": "webpack --mode development --watch"
13
+ },
14
+ "dependencies": {
15
+ "trestle": "https://github.com/TrestleAdmin/trestle.git"
16
+ },
17
+ "devDependencies": {
18
+ "autoprefixer": "^9.6.1",
19
+ "css-loader": "^3.2.0",
20
+ "mini-css-extract-plugin": "^0.8.0",
21
+ "node-sass": "^4.12.0",
22
+ "optimize-css-assets-webpack-plugin": "^5.0.3",
23
+ "postcss-loader": "^3.0.0",
24
+ "sass-loader": "^8.0.0",
25
+ "webpack": "^4.40.2",
26
+ "webpack-cli": "^3.3.9",
27
+ "webpack-fix-style-only-entries": "^0.4.0"
28
+ }
29
+ }
@@ -14,10 +14,10 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://www.trestle.io"
15
15
  spec.license = "LGPL-3.0"
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|node_modules)/}) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "trestle", "~> 0.8"
20
+ spec.add_dependency "trestle", "~> 0.9.0"
21
21
  spec.add_dependency "bcrypt", "~> 3.1.7"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.12"