authtown 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/lib/authtown/routes/rodauth.rb +7 -2
- data/lib/authtown/version.rb +1 -1
- data/lib/authtown.rb +47 -26
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5618c4b915887279ad6bfd3ba639756a63b92d1361fe3c5ef7d64fc1a9787f08
|
4
|
+
data.tar.gz: 488925cf2004d158d77893acfa68566469e19b29e03abfe48d6469b4a00ebbf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89644f9c86b9202faa8616c868956aa59a1f668418737092cb27181ba2a4d147886b6566a24c7110f3d91176acb279b92999c2cdd07b476b16466a9d4cdca1ea
|
7
|
+
data.tar.gz: 7323afa6ab4142c31a4eaf5f3e22d64fa8a7b0a106075328b299413bf2e7569ddad1017c7b428ca00a44938fd1a703b722def67e258c772816f75b8b3118b9cb
|
data/CHANGELOG.md
CHANGED
@@ -9,7 +9,11 @@ module Authtown
|
|
9
9
|
rodauth.load_memory
|
10
10
|
|
11
11
|
init_current_user
|
12
|
-
|
12
|
+
|
13
|
+
# hook :authtown, :initialized do |rodauth|
|
14
|
+
# Lifeform::Form.rodauth = rodauth
|
15
|
+
# end
|
16
|
+
Bridgetown::Hooks.trigger(:authtown, :initialized, rodauth)
|
13
17
|
|
14
18
|
r.on "auth" do
|
15
19
|
r.rodauth
|
@@ -20,7 +24,8 @@ module Authtown
|
|
20
24
|
Authtown::Current.user =
|
21
25
|
if rodauth.logged_in?
|
22
26
|
account_id = rodauth.account_from_session[:id]
|
23
|
-
|
27
|
+
user_class = bridgetown_site.config.authtown.user_class_resolver.()
|
28
|
+
user_class[account_id]
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
data/lib/authtown/version.rb
CHANGED
data/lib/authtown.rb
CHANGED
@@ -5,35 +5,50 @@ require "mail"
|
|
5
5
|
require "authtown/builder"
|
6
6
|
require "authtown/view_mixin"
|
7
7
|
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
# ActiveRecord schema:
|
8
|
+
# rubocop:disable Layout/LineLength
|
9
|
+
### Simple migration strategy:
|
12
10
|
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
11
|
+
# Sequel.migration do
|
12
|
+
# change do
|
13
|
+
# extension :date_arithmetic
|
14
|
+
|
15
|
+
# create_table(:users) do
|
16
|
+
# primary_key :id, type: :Bignum
|
17
|
+
# citext :email, null: false
|
18
|
+
# constraint :valid_email, email: /^[^,;@ \r\n]+@[^,@; \r\n]+\.[^,@; \r\n]+$/
|
19
|
+
# String :first_name
|
20
|
+
# String :password_hash, null: false
|
21
|
+
# index :email, unique: true
|
20
22
|
# end
|
21
|
-
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
|
29
|
-
#
|
23
|
+
|
24
|
+
# # Used by the remember me feature
|
25
|
+
# create_table(:account_remember_keys) do
|
26
|
+
# foreign_key :id, :users, primary_key: true, type: :Bignum
|
27
|
+
# String :key, null: false
|
28
|
+
# DateTime :deadline, { null: false, default: Sequel.date_add(Sequel::CURRENT_TIMESTAMP, days: 30) }
|
29
|
+
# end
|
30
|
+
|
31
|
+
# create_table(:account_password_reset_keys) do
|
32
|
+
# foreign_key :id, :users, primary_key: true, type: :Bignum
|
33
|
+
# String :key, null: false
|
34
|
+
# DateTime :deadline, { null: false, default: Sequel.date_add(Sequel::CURRENT_TIMESTAMP, days: 1) }
|
35
|
+
# DateTime :email_last_sent, null: false, default: Sequel::CURRENT_TIMESTAMP
|
30
36
|
# end
|
31
37
|
# end
|
32
38
|
# end
|
39
|
+
# rubocop:enable Layout/LineLength
|
33
40
|
|
34
|
-
|
35
|
-
|
36
|
-
|
41
|
+
Thread.attr_accessor :authtown_state
|
42
|
+
class Authtown::Current
|
43
|
+
class << self
|
44
|
+
def thread_state = Thread.current.authtown_state ||= {}
|
45
|
+
|
46
|
+
def user=(new_user)
|
47
|
+
thread_state[:user] = new_user
|
48
|
+
end
|
49
|
+
|
50
|
+
def user = thread_state[:user]
|
51
|
+
end
|
37
52
|
end
|
38
53
|
|
39
54
|
# rubocop:disable Metrics/BlockLength
|
@@ -42,9 +57,13 @@ end
|
|
42
57
|
Bridgetown.initializer :authtown do |
|
43
58
|
config,
|
44
59
|
rodauth_config: nil,
|
45
|
-
account_landing_page: "/account/profile"
|
60
|
+
account_landing_page: "/account/profile",
|
61
|
+
user_class_resolver: -> { User }
|
46
62
|
|
|
47
63
|
|
64
|
+
config.authtown ||= {}
|
65
|
+
config.authtown.user_class_resolver ||= user_class_resolver
|
66
|
+
|
48
67
|
config.only :server do
|
49
68
|
require "authtown/routes/rodauth"
|
50
69
|
|
@@ -56,9 +75,11 @@ Bridgetown.initializer :authtown do |
|
|
56
75
|
app.plugin(:sessions, secret:)
|
57
76
|
|
58
77
|
app.plugin :rodauth do
|
59
|
-
enable :login, :logout, :create_account, :remember, :reset_password
|
78
|
+
enable :login, :logout, :create_account, :remember, :reset_password, :internal_request
|
60
79
|
hmac_secret secret
|
61
80
|
|
81
|
+
base_url config.url
|
82
|
+
|
62
83
|
prefix "/auth"
|
63
84
|
|
64
85
|
login_redirect account_landing_page
|
@@ -92,7 +113,7 @@ Bridgetown.initializer :authtown do |
|
|
92
113
|
# Make sure timestamps get saved
|
93
114
|
account[:created_at] = account[:updated_at] = Time.now
|
94
115
|
|
95
|
-
account[:first_name] = param(:first_name)
|
116
|
+
account[:first_name] = param(:first_name) if param(:first_name)
|
96
117
|
end
|
97
118
|
|
98
119
|
after_login do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authtown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bridgetown
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
157
|
+
rubygems_version: 3.5.3
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Rodauth integration for Bridgetown
|