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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfad604f4745dd7570ce2d3312be76883c4628d78b68f9cf73e895524e3a5b09
4
- data.tar.gz: 8075becb0053683c3829418f3638203ec18e68c8457889e991d0f00330272c79
3
+ metadata.gz: 7acbcb69df24a8f4cc70e5679ddee87b6ae96a031fa16eefdbe364aca086127e
4
+ data.tar.gz: 494132b0b91cf59fde8afb705768824af1aa6ec7ccae6cbaa00aa1ff385595f9
5
5
  SHA512:
6
- metadata.gz: 232ad1c394f2587baab5d9756a9bbd5a5aeb7a2367a62e650a7005ac8f65159d9394871295005aaa54834e69c53ce272d8366faec645498981b81f1770d88403
7
- data.tar.gz: e19a765822a158ff63482d267ab4d3e231ca5024f21abf239ac783f4818d3629c6731bb1967c5a7b674992ea404b0b38efdecf341f1e8da92e71a07577878aee
6
+ metadata.gz: bab4269085274c79c172220c6f19e3e5c061f75f63e46efddc45dca0208f59aa8c78fa6b1c88862585fe1b4d9fef0b503bb531ff9d3bdda5bf64271052b5f2c7
7
+ data.tar.gz: fab03417c2685ece0c56a4d5d169ebdb6fb2c78d708987618074ae12120cb2fa3a183f3a72561e484e4b5e3b79ce888ed87ba0daf18a22bbcc59af3690a1d047
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- administration-zero (0.0.11)
4
+ administration-zero (0.0.12)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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,3 +1,3 @@
1
1
  module AdministrationZero
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -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) => {
@@ -1,3 +1,3 @@
1
1
  class Admin::Current < ActiveSupport::CurrentAttributes
2
- attribute :user
2
+ attribute :user; resets { Time.zone = nil }
3
3
  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.11
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-08 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: