administration-zero 0.0.17 → 0.0.18
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -5
- data/lib/administration_zero/version.rb +1 -1
- data/lib/generators/admin/install/templates/controllers/admin/base_controller.rb +10 -9
- data/lib/generators/admin/install/templates/controllers/admin/password_resets_controller.rb +5 -1
- data/lib/generators/admin/install/templates/erb/admin/base/_javascript_tags.html.erb +4 -3
- data/lib/generators/admin/install/templates/erb/admin/base/_stylesheet_link_tags.html.erb +1 -1
- data/lib/generators/admin/install/templates/helpers/admin/application_helper.rb +2 -16
- data/lib/generators/admin/install/templates/models/admin/user.rb +2 -2
- metadata +2 -3
- data/lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset.text.erb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 002cc16c4991ff76fa333e03d38220537d021c2eff150ea87b6456db59da6fb2
|
4
|
+
data.tar.gz: 16336855dbac4b38d7fe2ca0a0336aebb4a0812e9cd89e19b69aebeef4d97745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 742ce20b62c3357138c6088e6eeb972410a38df4c53482473ba8d43c2e58cede13d7b6ab657318d3dfed9a5b1ffc25be44fede6e391749c3b9cc9ddc3b18553c
|
7
|
+
data.tar.gz: 2490f2b73022d79f1e6867775f2e52657adc0cae61f6b85d9c718be45018164b289f7611e705ea7d200d74e0faa9e1db8fb958b3c3107072b167c39c258e6c57
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -18,14 +18,10 @@ The purpose of administration zero is to generate a pre-built administration pan
|
|
18
18
|
|
19
19
|
## Installation
|
20
20
|
|
21
|
-
Add this line to your application's Gemfile:
|
22
|
-
|
23
21
|
```ruby
|
24
|
-
|
22
|
+
bundle add administration-zero
|
25
23
|
```
|
26
24
|
|
27
|
-
Then run `bundle install`
|
28
|
-
|
29
25
|
You'll need to create a model to be administrated, if you don't have one. for this example let's use the following:
|
30
26
|
|
31
27
|
```
|
@@ -4,15 +4,16 @@ class Admin::BaseController < ActionController::Base
|
|
4
4
|
before_action :set_time_zone
|
5
5
|
before_action :authenticate
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
private
|
8
|
+
def set_time_zone
|
9
|
+
Time.zone = cookies[:time_zone]
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
def authenticate
|
13
|
+
if user = Admin::User.find_by_id(session[:admin_user_id])
|
14
|
+
Admin::Current.user = user
|
15
|
+
else
|
16
|
+
redirect_to admin_sign_in_path
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
end
|
@@ -13,7 +13,7 @@ class Admin::PasswordResetsController < Admin::BaseController
|
|
13
13
|
|
14
14
|
def create
|
15
15
|
if @user = Admin::User.find_by(email: params[:email])
|
16
|
-
|
16
|
+
send_password_reset_email
|
17
17
|
redirect_to admin_sign_in_path, notice: "Check your email for reset instructions"
|
18
18
|
else
|
19
19
|
redirect_to new_admin_password_reset_path, alert: "Sorry, we didn't recognize that email address"
|
@@ -38,4 +38,8 @@ class Admin::PasswordResetsController < Admin::BaseController
|
|
38
38
|
def user_params
|
39
39
|
params.permit(:password, :password_confirmation)
|
40
40
|
end
|
41
|
+
|
42
|
+
def send_password_reset_email
|
43
|
+
Admin::UserMailer.with(user: @user).password_reset.deliver_later
|
44
|
+
end
|
41
45
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<!-- Tabler Core -->
|
2
|
-
<script src="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-
|
2
|
+
<script src="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/js/tabler.min.js"></script>
|
3
3
|
|
4
4
|
<!-- Time zone cookie -->
|
5
5
|
<script type="module">
|
@@ -12,15 +12,16 @@
|
|
12
12
|
<script type="module">
|
13
13
|
document.addEventListener("click", (event) => {
|
14
14
|
if (!event.target.matches("[data-confirm]")) return
|
15
|
-
if (!
|
15
|
+
if (!confirm(event.target.dataset["confirm"])) event.preventDefault()
|
16
16
|
})
|
17
17
|
</script>
|
18
18
|
|
19
19
|
<!-- Stimulus controllers -->
|
20
20
|
<script type="module">
|
21
|
-
import { Application, Controller } from "https://cdn.jsdelivr.net/npm
|
21
|
+
import { Application, Controller } from "https://cdn.jsdelivr.net/npm/stimulus@3.2.1/dist/stimulus.min.js"
|
22
22
|
window.Stimulus = Application.start()
|
23
23
|
|
24
|
+
// Flash message
|
24
25
|
Stimulus.register("flash-message", class extends Controller {
|
25
26
|
connect() {
|
26
27
|
new bootstrap.Toast(this.element).show()
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<!-- Tabler Core -->
|
2
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-
|
2
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/css/tabler.min.css">
|
3
3
|
|
4
4
|
<!-- Customize tabler here -->
|
5
5
|
<style>body {
|
@@ -5,24 +5,10 @@ module Admin::ApplicationHelper
|
|
5
5
|
content_for(:title) || Rails.application.class.to_s.split("::").first
|
6
6
|
end
|
7
7
|
|
8
|
-
def active_nav_item(controller, actions = %w(
|
9
|
-
|
8
|
+
def active_nav_item(controller, actions = %w(index show new edit create update))
|
9
|
+
active_actions?(controller, actions) ? "active" : ""
|
10
10
|
end
|
11
11
|
|
12
|
-
def np(number, options = {})
|
13
|
-
number_with_precision number, options
|
14
|
-
end
|
15
|
-
|
16
|
-
def nd(number, options = {})
|
17
|
-
number_with_delimiter number, options
|
18
|
-
end
|
19
|
-
|
20
|
-
def localize(object, **options)
|
21
|
-
super(object, **options) if object
|
22
|
-
end
|
23
|
-
|
24
|
-
alias :l :localize
|
25
|
-
|
26
12
|
private
|
27
13
|
def active_actions?(controller, actions)
|
28
14
|
params[:controller].include?(controller) && actions.include?(params[:action])
|
@@ -4,7 +4,7 @@ class Admin::User < Admin::ApplicationRecord
|
|
4
4
|
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
5
5
|
validates :password, allow_nil: true, length: { minimum: 12 }, format: { with: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/ }
|
6
6
|
|
7
|
-
before_validation do
|
8
|
-
self.email = email.
|
7
|
+
before_validation if: -> { email.present? } do
|
8
|
+
self.email = email.downcase.strip
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administration-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -53,7 +53,6 @@ files:
|
|
53
53
|
- lib/generators/admin/install/templates/erb/admin/password_resets/new.html.erb
|
54
54
|
- lib/generators/admin/install/templates/erb/admin/sessions/new.html.erb
|
55
55
|
- lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset.html.erb
|
56
|
-
- lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset.text.erb
|
57
56
|
- lib/generators/admin/install/templates/erb/admin/users/_form.html.erb
|
58
57
|
- lib/generators/admin/install/templates/erb/admin/users/edit.html.erb
|
59
58
|
- lib/generators/admin/install/templates/erb/admin/users/index.html.erb
|
@@ -1,9 +0,0 @@
|
|
1
|
-
Hey there,
|
2
|
-
|
3
|
-
Can't remember your password for <%= @user.email %>? That's OK, it happens. Just hit the link below to set a new one.
|
4
|
-
|
5
|
-
[Reset my password]<%= edit_admin_password_reset_url(token: @signed_id) %>
|
6
|
-
|
7
|
-
If you did not request a password reset you can safely ignore this email, it expires in 20 minutes. Only someone with access to this email account can reset your password.
|
8
|
-
|
9
|
-
Have questions or need help? Just reply to this email and our support team will help you sort it out.
|