administration-zero 0.0.17 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +10 -18
- 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: f33382ad3760ecfd1ab0cea402939763e49c2c80913abda93e23c9142fdf3293
|
4
|
+
data.tar.gz: 35c3b4570ea9d480cd142df44ef676daf5fc794734827749606f1a449809b49e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2332226c5e149e3888d81e62583855938992d23e35502c0b2718e42b53abb678ab28029870776a79484513db2ae000553c19d5e56b6d1ed0005921145f60712b
|
7
|
+
data.tar.gz: 5c6303d63569190b71e0f99b81df55308fccf6dc6f39042ebac8031f1e2a3e237bba37d0a8664d59370384b3cbf20c75e34c03aa9daf0dda0766aee2a696bd39
|
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,24 +1,9 @@
|
|
1
|
-
|
2
|
-
<script src="https://cdn.jsdelivr.net/npm/@
|
3
|
-
|
4
|
-
<!-- Time zone cookie -->
|
5
|
-
<script type="module">
|
6
|
-
import cookies from "https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.mjs"
|
7
|
-
const { timeZone } = new Intl.DateTimeFormat().resolvedOptions()
|
8
|
-
cookies.set("time_zone", timeZone, { expires: 365 })
|
9
|
-
</script>
|
10
|
-
|
11
|
-
<!-- Data confirm -->
|
12
|
-
<script type="module">
|
13
|
-
document.addEventListener("click", (event) => {
|
14
|
-
if (!event.target.matches("[data-confirm]")) return
|
15
|
-
if (!window.confirm(event.target.dataset["confirm"])) event.preventDefault()
|
16
|
-
})
|
17
|
-
</script>
|
1
|
+
<script src="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/js/tabler.min.js"></script>
|
2
|
+
<script src="https://cdn.jsdelivr.net/npm/@rails/ujs@7.0.4-2/lib/assets/compiled/rails-ujs.min.js"></script>
|
18
3
|
|
19
4
|
<!-- Stimulus controllers -->
|
20
5
|
<script type="module">
|
21
|
-
import { Application, Controller } from "https://cdn.jsdelivr.net/npm
|
6
|
+
import { Application, Controller } from "https://cdn.jsdelivr.net/npm/stimulus@3.2.1/dist/stimulus.min.js"
|
22
7
|
window.Stimulus = Application.start()
|
23
8
|
|
24
9
|
Stimulus.register("flash-message", class extends Controller {
|
@@ -27,3 +12,10 @@
|
|
27
12
|
}
|
28
13
|
})
|
29
14
|
</script>
|
15
|
+
|
16
|
+
<!-- Time zone cookie -->
|
17
|
+
<script type="module">
|
18
|
+
import Cookies from "https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.mjs"
|
19
|
+
const { timeZone } = new Intl.DateTimeFormat().resolvedOptions()
|
20
|
+
Cookies.set("time_zone", timeZone, { expires: 365 })
|
21
|
+
</script>
|
@@ -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: 1.0.0
|
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-02 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.
|