administration-zero 0.0.11 → 0.0.12
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 -0
- data/lib/administration_zero/version.rb +1 -1
- data/lib/generators/admin/install/templates/controllers/admin/application_controller.rb +5 -0
- data/lib/generators/admin/install/templates/controllers/admin/sessions_controller.rb +1 -2
- data/lib/generators/admin/install/templates/erb/admin/application/_javascript_tags.html.erb +14 -0
- data/lib/generators/admin/install/templates/models/admin/current.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7acbcb69df24a8f4cc70e5679ddee87b6ae96a031fa16eefdbe364aca086127e
|
4
|
+
data.tar.gz: 494132b0b91cf59fde8afb705768824af1aa6ec7ccae6cbaa00aa1ff385595f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bab4269085274c79c172220c6f19e3e5c061f75f63e46efddc45dca0208f59aa8c78fa6b1c88862585fe1b4d9fef0b503bb531ff9d3bdda5bf64271052b5f2c7
|
7
|
+
data.tar.gz: fab03417c2685ece0c56a4d5d169ebdb6fb2c78d708987618074ae12120cb2fa3a183f3a72561e484e4b5e3b79ce888ed87ba0daf18a22bbcc59af3690a1d047
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -11,6 +11,7 @@ The purpose of administration zero is to generate a pre-built administration pan
|
|
11
11
|
- [Sortable and filterable](https://github.com/activerecord-hackery/ransack)
|
12
12
|
- [Exportable data](https://github.com/westonganger/spreadsheet_architect)
|
13
13
|
- [Toastr for flash messages](https://getbootstrap.com/docs/5.1/components/toasts)
|
14
|
+
- Determine time zone automatically
|
14
15
|
- Easy authentication system
|
15
16
|
- Admin scaffolds
|
16
17
|
|
@@ -1,8 +1,13 @@
|
|
1
1
|
class Admin::ApplicationController < ActionController::Base
|
2
2
|
include Pagy::Backend
|
3
3
|
|
4
|
+
before_action :set_time_zone
|
4
5
|
before_action :authenticate
|
5
6
|
|
7
|
+
def set_time_zone
|
8
|
+
Time.zone = cookies[:time_zone]
|
9
|
+
end
|
10
|
+
|
6
11
|
def authenticate
|
7
12
|
if admin_user = Admin::User.find_by_id(session[:admin_user_id])
|
8
13
|
Admin::Current.user = admin_user
|
@@ -11,8 +11,7 @@ class Admin::SessionsController < Admin::ApplicationController
|
|
11
11
|
@admin_user = Admin::User.find_by(email: params[:email])
|
12
12
|
|
13
13
|
if @admin_user && @admin_user.authenticate(params[:password])
|
14
|
-
session[:admin_user_id] = @admin_user.id
|
15
|
-
redirect_to admin_path
|
14
|
+
session[:admin_user_id] = @admin_user.id; redirect_to(admin_path)
|
16
15
|
else
|
17
16
|
redirect_to admin_sign_in_path(email_hint: params[:email]), alert: "That email or password is incorrect"
|
18
17
|
end
|
@@ -1,6 +1,20 @@
|
|
1
1
|
<!-- Tabler Core -->
|
2
2
|
<script src="https://unpkg.com/@tabler/core@1.0.0-beta9/dist/js/tabler.min.js"></script>
|
3
3
|
|
4
|
+
<!-- set time zone cookie -->
|
5
|
+
<script>
|
6
|
+
const { timeZone } = new Intl.DateTimeFormat().resolvedOptions();
|
7
|
+
setCookie("time_zone", timeZone);
|
8
|
+
|
9
|
+
function setCookie(name, value) {
|
10
|
+
const twentyYears = 20 * 365 * 24 * 60 * 60 * 1000;
|
11
|
+
const body = [ name, value ].map(encodeURIComponent).join("=");
|
12
|
+
const expires = new Date(Date.now() + twentyYears).toUTCString();
|
13
|
+
const cookie = `${body}; path=/; expires=${expires}`;
|
14
|
+
document.cookie = cookie;
|
15
|
+
}
|
16
|
+
</script>
|
17
|
+
|
4
18
|
<!-- bring back data-confirm -->
|
5
19
|
<script>
|
6
20
|
document.addEventListener("click", (event) => {
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|