card-mod-account 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/style/account.scss +36 -0
- data/data/real.yml +300 -0
- data/db/migrate_core_cards/20220815112551_move_roles.rb +47 -0
- data/locales/de.yml +1 -1
- data/locales/en.yml +1 -1
- data/set/abstract/account_field.rb +1 -3
- data/set/abstract/accountable.rb +1 -1
- data/set/all/account.rb +4 -7
- data/set/right/account/events.rb +3 -3
- data/set/right/account/views.rb +2 -1
- data/set/right/account.rb +1 -3
- data/set/right/email.rb +3 -1
- data/set/right/password.rb +3 -4
- data/set/right/roles.rb +5 -23
- data/set/right/salt.rb +2 -0
- data/set/right/status.rb +4 -2
- data/set/self/role.rb +38 -0
- data/set/self/signin.rb +13 -10
- data/set/type/role.rb +3 -1
- data/set/type/signup/views.rb +3 -3
- data/set/type/signup.rb +5 -3
- data/set/type/user/setup_help.haml +1 -1
- data/set/type/user.rb +8 -3
- data/set/type_plus_right/role/members.rb +5 -0
- data/set/type_plus_right/user/email.rb +4 -0
- metadata +45 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6746b209fb026dba9a6d3954907e85d8e2d7fe41d0f3b19e7abccbe564e75b19
|
4
|
+
data.tar.gz: 84fa785cfd4022c10b6b491aaacdfa352903f86c9a2f2e1379c352508b74df51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47734b784a923c88b2720564c86b55ef8c335f84beaf1d6ccb40e90b8fa786a45e0497d32f9f12f41c3f62778ca2d9f06426803f8754b0a911be451e2372904c
|
7
|
+
data.tar.gz: c50dbdc1ef16286cc8c80957fdf30e8ad7e5c6bf176838b87377bb086bcb20bf21d6e81fc9eb5abe9efd37fcd650541e2d31031c09e93c88a42db9605dc4cedb
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/*----------- (Account Request)--------------*/
|
2
|
+
|
3
|
+
.invite-links {
|
4
|
+
padding: 10px;
|
5
|
+
margin-top: 10px;
|
6
|
+
text-align: center;
|
7
|
+
a {
|
8
|
+
font-weight: bold;
|
9
|
+
margin: 0 20px;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
/*-- sign in page --*/
|
14
|
+
|
15
|
+
#sign-in input#login_field,
|
16
|
+
#sign-in input#password,
|
17
|
+
#forgot-password input#email {
|
18
|
+
width: 50%;
|
19
|
+
}
|
20
|
+
|
21
|
+
#forgot-password {
|
22
|
+
margin-top: 40px;
|
23
|
+
}
|
24
|
+
|
25
|
+
.new-account-link {
|
26
|
+
text-align: center;
|
27
|
+
}
|
28
|
+
|
29
|
+
.form-group .signup-link {
|
30
|
+
display: inline;
|
31
|
+
}
|
32
|
+
|
33
|
+
// FIXME - decko should handle better
|
34
|
+
#my-card-link {
|
35
|
+
padding-right: 0.6em;
|
36
|
+
}
|
data/data/real.yml
ADDED
@@ -0,0 +1,300 @@
|
|
1
|
+
---
|
2
|
+
# Cardtypes
|
3
|
+
|
4
|
+
- :name: Role
|
5
|
+
:type: :cardtype
|
6
|
+
:codename: role
|
7
|
+
:fields:
|
8
|
+
:description: |-
|
9
|
+
Each [[user]] can be given roles to organize site permissions.
|
10
|
+
[[http://decko.org/Role|Learn more about roles]].
|
11
|
+
|
12
|
+
- :name: "*members"
|
13
|
+
:codename: members
|
14
|
+
|
15
|
+
|
16
|
+
# Roles
|
17
|
+
|
18
|
+
- :name: Anyone
|
19
|
+
:type: :role
|
20
|
+
:codename: anyone
|
21
|
+
:fields:
|
22
|
+
:description: |-
|
23
|
+
Everyone has this role, whether signed in or not. [[http://decko.org/account|more]]
|
24
|
+
- :name: Anyone Signed In
|
25
|
+
:type: :role
|
26
|
+
:codename: anyone_signed_in
|
27
|
+
:fields:
|
28
|
+
:description: |-
|
29
|
+
Anyone who is signed in has this role. [[http://decko.org/account|more]]
|
30
|
+
- :name: Administrator
|
31
|
+
:type: :role
|
32
|
+
:codename: administrator
|
33
|
+
:fields:
|
34
|
+
:description: |-
|
35
|
+
[[_left+:members|Administrators]] can create, read, update and delete any card.
|
36
|
+
[[http://decko.org/permissions|more]]
|
37
|
+
:members:
|
38
|
+
:fields:
|
39
|
+
:self:
|
40
|
+
:fields:
|
41
|
+
:update: Administrator
|
42
|
+
- :name: Eagle
|
43
|
+
:type: :role
|
44
|
+
:codename: eagle
|
45
|
+
:fields:
|
46
|
+
:description: "[[Eagle+:members|Eagle users]] can add and edit content."
|
47
|
+
- :name: Shark
|
48
|
+
:type: :role
|
49
|
+
:codename: shark
|
50
|
+
:fields:
|
51
|
+
:description: |-
|
52
|
+
[[_left+:members|Shark users]] can configure the deck and create structures.
|
53
|
+
:members:
|
54
|
+
:fields:
|
55
|
+
:self:
|
56
|
+
:fields:
|
57
|
+
:update: Administrator
|
58
|
+
- :name: Help Desk
|
59
|
+
:type: :role
|
60
|
+
:codename: help_desk
|
61
|
+
:fields:
|
62
|
+
:description: |-
|
63
|
+
[[_left+*members|Help Desk users]] can manage accounts and edit help text.
|
64
|
+
:members:
|
65
|
+
:fields:
|
66
|
+
:self:
|
67
|
+
:fields:
|
68
|
+
:update: Administrator
|
69
|
+
- :name: Anonymous
|
70
|
+
:codename: anonymous
|
71
|
+
:content: "<p>Edits made by people who are not signed in are credited to Anonymous.
|
72
|
+
[[http://decko.org/account|Learn more about accounts]].</p>"
|
73
|
+
|
74
|
+
- :name:
|
75
|
+
- :role
|
76
|
+
- :members
|
77
|
+
- :type_plus_right
|
78
|
+
- :update
|
79
|
+
:content:
|
80
|
+
Help Desk
|
81
|
+
|
82
|
+
- :name: "*account"
|
83
|
+
:codename: account
|
84
|
+
:fields:
|
85
|
+
:right:
|
86
|
+
:fields:
|
87
|
+
:create: Administrator
|
88
|
+
:read: Help Desk
|
89
|
+
:update: Help Desk
|
90
|
+
:delete: Help Desk
|
91
|
+
:content: |-
|
92
|
+
<div>When someone signs up, they create a [[Sign up]] card...</div>
|
93
|
+
<blockquote>
|
94
|
+
<div>{{Sign up|closed;title: Sign ups}}</div>
|
95
|
+
</blockquote>
|
96
|
+
<div>...that can be changed into a [[User]] card:</div>
|
97
|
+
<blockquote>
|
98
|
+
<div>{{User|title: Users; closed}}</div>
|
99
|
+
</blockquote>
|
100
|
+
<div>Some important [[http://decko.org/permissions|permissions]]:</div>
|
101
|
+
<div>
|
102
|
+
<ul>
|
103
|
+
<li>When [[Anyone]] can [[*create|create]] a [[Sign up]] card, links to sign up will appear.</li>
|
104
|
+
<li>When [[Anyone]] can [[*create|create]] a [[User]] card, each [[Sign up]] can be auto-approved with a verification email.</li>
|
105
|
+
<li>If permission to [[*create|create]] a [[User]] is restricted, someone with that permission must approve each [[Sign up]] by hand.</li>
|
106
|
+
</ul>
|
107
|
+
</div>
|
108
|
+
<h5>Related links</h5>
|
109
|
+
<ul>
|
110
|
+
<li><em>[[http://decko.org/account | Accounts docs]]</em></li>
|
111
|
+
<li><em>[[Cards with accounts]]</em></li>
|
112
|
+
<li><em>[[:account+:right+:by_name|Account cards]]</em></li>
|
113
|
+
</ul>
|
114
|
+
|
115
|
+
# :account fields
|
116
|
+
|
117
|
+
- :name: "*email"
|
118
|
+
:codename: email
|
119
|
+
:fields:
|
120
|
+
:right:
|
121
|
+
:fields:
|
122
|
+
:update: Help Desk
|
123
|
+
:delete: Help Desk
|
124
|
+
:read: Help Desk
|
125
|
+
- :name: "*password"
|
126
|
+
:codename: password
|
127
|
+
:fields:
|
128
|
+
:right:
|
129
|
+
:fields:
|
130
|
+
:update: Help Desk
|
131
|
+
:delete: Help Desk
|
132
|
+
:read: Help Desk
|
133
|
+
- :name: "*salt"
|
134
|
+
:codename: salt
|
135
|
+
:fields:
|
136
|
+
:right:
|
137
|
+
:fields:
|
138
|
+
:read: Help Desk
|
139
|
+
- :name: "*status"
|
140
|
+
:codename: status
|
141
|
+
:fields:
|
142
|
+
:right:
|
143
|
+
:fields:
|
144
|
+
:update: Help Desk
|
145
|
+
:delete: Help Desk
|
146
|
+
:read: Help Desk
|
147
|
+
|
148
|
+
- :name: "*account settings"
|
149
|
+
:codename: account_settings
|
150
|
+
:fields:
|
151
|
+
:right:
|
152
|
+
:fields:
|
153
|
+
:structure: |-
|
154
|
+
{{_left+:account|content}}
|
155
|
+
{{_left+:roles|title: Roles}}
|
156
|
+
{{_left+:follow|title: Notification choices}}
|
157
|
+
|
158
|
+
- :name: Sign up
|
159
|
+
:type: :cardtype
|
160
|
+
:codename: signup
|
161
|
+
:fields:
|
162
|
+
:description: |-
|
163
|
+
[[Sign up]] cards represent not-yet-approved accounts.
|
164
|
+
When approved, they become [[User]] cards. [[http://decko.org/account|more]]
|
165
|
+
:self:
|
166
|
+
:fields:
|
167
|
+
:structure: |-
|
168
|
+
<p>{{+:description|content}}</p>
|
169
|
+
<h2>{{_self|name}} Cards</h2>
|
170
|
+
<blockquote><p>{{+:type+:by_name|content}}</p></blockquote>
|
171
|
+
:type:
|
172
|
+
:fields:
|
173
|
+
:create: Anyone
|
174
|
+
:on_create: signup alert email
|
175
|
+
:account:
|
176
|
+
:fields:
|
177
|
+
:type_plus_right:
|
178
|
+
:fields:
|
179
|
+
:create: _left
|
180
|
+
- :name:
|
181
|
+
- :user
|
182
|
+
- :account
|
183
|
+
- :type_plus_right
|
184
|
+
- :create
|
185
|
+
:content: _left
|
186
|
+
|
187
|
+
- :name:
|
188
|
+
- :wagn_bot
|
189
|
+
- :account
|
190
|
+
:fields:
|
191
|
+
:email: no-reply@decko.org
|
192
|
+
|
193
|
+
- :name: welcome email
|
194
|
+
:type: :email_template
|
195
|
+
:codename: welcome_email
|
196
|
+
- :name: verification email
|
197
|
+
:type: :email_template
|
198
|
+
:codename: verification_email
|
199
|
+
:fields:
|
200
|
+
:from: Decko Bot
|
201
|
+
:subject: verification link for {{:title|core}}
|
202
|
+
:html_message: |-
|
203
|
+
<div style="text-align:center">
|
204
|
+
<h1>Thank you for signing up with {{:title|core}}!</h1>
|
205
|
+
<p>
|
206
|
+
Please <a href="{{_|verify_url}}">follow this link</a>
|
207
|
+
to verify this email address and activate your account.
|
208
|
+
</p>
|
209
|
+
<p><em>Link will remain valid for {{_|verify_days}} days.</em></p>
|
210
|
+
</div>
|
211
|
+
:text_message: |+
|
212
|
+
Thank you for signing up with {{:title|core}}!
|
213
|
+
|
214
|
+
Please follow the link below to verify this email address and activate your account.
|
215
|
+
|
216
|
+
{{_|verify_url}}
|
217
|
+
(Link will remain valid for {{_|verify_days}} days.)
|
218
|
+
- :name: password reset email
|
219
|
+
:type: :email_template
|
220
|
+
:codename: password_reset_email
|
221
|
+
:fields:
|
222
|
+
:from: Decko Bot
|
223
|
+
:subject: reset password for {{:title|core}}
|
224
|
+
:text_message: "** Password reset for {{:title|core}} **\n\nSomeone – you, we hope –
|
225
|
+
asked to reset your password. Please follow this link...\n\n {{_|reset_password_url}}\n
|
226
|
+
\ \n...to update your account details.\n\n\n(Link will remain valid for {{_|reset_password_days}}
|
227
|
+
days.)\n\n"
|
228
|
+
:html_message: "<div style=\"text-align:center\">\n
|
229
|
+
<h1>Password reset for {{:title|core}}</h1>\n
|
230
|
+
\ \n <p>Someone – you, we hope – asked to reset your password.</p>\n \n <p>Please
|
231
|
+
<a href=\"{{_|reset_password_url}}\">follow this link</a> to update your account
|
232
|
+
details.</p>\n \n <p><em>Link will remain valid for {{_|reset_password_days}}
|
233
|
+
days.</em></p>\n</div>\n\n"
|
234
|
+
- :name: signup alert email
|
235
|
+
:type: :email_template
|
236
|
+
:codename: signup_alert_email
|
237
|
+
:fields:
|
238
|
+
:from: _user
|
239
|
+
:subject: "{{_|name}} signed up for {{:title|core}}"
|
240
|
+
:text_message: |
|
241
|
+
{{_|name}} has signed up on {{:title|core}}.
|
242
|
+
|
243
|
+
See {{_|name}}'s card: {{_|url}}
|
244
|
+
|
245
|
+
-- the machines running {{:title|core}}
|
246
|
+
:html_message: |
|
247
|
+
<p>
|
248
|
+
{{_|name}}
|
249
|
+
has <a href="{{_|url}}">signed up</a>
|
250
|
+
on {{:title|core}}.
|
251
|
+
</p>
|
252
|
+
|
253
|
+
<p><em>-- the machines running {{:title|core}}</em></p>
|
254
|
+
|
255
|
+
|
256
|
+
- :name: "*signin"
|
257
|
+
:codename: signin
|
258
|
+
:conflict: :defer
|
259
|
+
:fields:
|
260
|
+
:self:
|
261
|
+
:fields:
|
262
|
+
:update: Anyone
|
263
|
+
- :name: "*roles"
|
264
|
+
:codename: roles
|
265
|
+
:fields:
|
266
|
+
:right:
|
267
|
+
:fields:
|
268
|
+
:input_type: checkbox
|
269
|
+
:content_options:
|
270
|
+
:type: :search_type
|
271
|
+
:content: '{"type":"role", "not":{"codename":["in","anyone","anyone_signed_in"]}}'
|
272
|
+
|
273
|
+
|
274
|
+
- :name: "*enabled roles"
|
275
|
+
:codename: enabled_roles
|
276
|
+
- :name: "*account links"
|
277
|
+
:codename: account_links
|
278
|
+
|
279
|
+
- :name: Cards with accounts
|
280
|
+
:type: :search_type
|
281
|
+
:codename: cards_with_account
|
282
|
+
:content: '{"right_plus": ":account"}'
|
283
|
+
|
284
|
+
- :name: "*thanks"
|
285
|
+
:type: :setting
|
286
|
+
:codename: thanks
|
287
|
+
- :name:
|
288
|
+
- :signup
|
289
|
+
- :type
|
290
|
+
- :thanks
|
291
|
+
:type: :phrase
|
292
|
+
:content: :signup_success
|
293
|
+
|
294
|
+
- :name: Signup Success
|
295
|
+
:codename: signup_success
|
296
|
+
:content: |-
|
297
|
+
<div>
|
298
|
+
Thank you for signing up with {{:title|core}}.
|
299
|
+
You should receive a response in your email.
|
300
|
+
</div>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
class MoveRoles < Cardio::Migration
|
4
|
+
def up
|
5
|
+
remove_member_structure_rule
|
6
|
+
change_existing_member_cards_to_lists
|
7
|
+
populate_member_lists_and_delete_role_lists
|
8
|
+
end
|
9
|
+
|
10
|
+
def remove_member_structure_rule
|
11
|
+
%i[members right structure].card&.delete!
|
12
|
+
end
|
13
|
+
|
14
|
+
def change_existing_member_cards_to_lists
|
15
|
+
Card.search(left: { type_id: Card::RoleID },
|
16
|
+
right_id: Card::MembersID) do |role_members|
|
17
|
+
role_members.update! type_id: Card::ListID
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def populate_member_lists_and_delete_role_lists
|
22
|
+
Card.search(left: { type_id: Card::UserID },
|
23
|
+
right_id: Card::RolesID) do |user_roles|
|
24
|
+
role_names = role_names_from_user_roles_card user_roles.id
|
25
|
+
move_role_names user_roles.left.name, role_names if role_names.present?
|
26
|
+
user_roles.delete
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def move_role_names user, role_names
|
31
|
+
role_names.each do |role_name|
|
32
|
+
next unless role_name.card&.type_code == :role
|
33
|
+
|
34
|
+
puts "Move #{user} to role #{role_name}"
|
35
|
+
Card.fetch(role_name, :members, new: {}).add_item! user
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def role_names_from_user_roles_card id
|
40
|
+
query = "SELECT db_content FROM cards WHERE cards.id = #{id}"
|
41
|
+
content = ActiveRecord::Base.connection
|
42
|
+
.exec_query(query)
|
43
|
+
.rows&.first&.first
|
44
|
+
return unless content.present?
|
45
|
+
content.split "\n"
|
46
|
+
end
|
47
|
+
end
|
data/locales/de.yml
CHANGED
@@ -104,7 +104,7 @@ de:
|
|
104
104
|
account_password_missing: Passwort muss angegeben werden
|
105
105
|
account_private_data: Private Daten
|
106
106
|
account_reset_my_password: Passwort zurücksetzen
|
107
|
-
account_reset_password:
|
107
|
+
account_reset_password: Password Zurücksetzen
|
108
108
|
account_search_email_duplicate: E-Mail-Duplikat? (%{content})
|
109
109
|
account_sign_in: Anmelden
|
110
110
|
account_sign_in_title: Anmelden
|
data/locales/en.yml
CHANGED
@@ -21,7 +21,7 @@ en:
|
|
21
21
|
account_password_missing: password can't be blank
|
22
22
|
account_private_data: Private data
|
23
23
|
account_reset_my_password: Reset my password
|
24
|
-
account_reset_password:
|
24
|
+
account_reset_password: Reset Password
|
25
25
|
account_search_email_duplicate: email duplicate? (%{content})
|
26
26
|
account_sign_in: Sign in
|
27
27
|
account_sign_in_title: Sign In
|
@@ -6,9 +6,7 @@ end
|
|
6
6
|
|
7
7
|
# allow account owner to update account field content
|
8
8
|
def ok_to_update
|
9
|
-
|
10
|
-
|
11
|
-
super
|
9
|
+
(own_account? && !name_changed? && !type_id_changed?) || super
|
12
10
|
end
|
13
11
|
|
14
12
|
# force inherit permission on create
|
data/set/abstract/accountable.rb
CHANGED
@@ -37,7 +37,7 @@ format :html do
|
|
37
37
|
["Email and Password", :account,
|
38
38
|
{ path: { slot: { hide: %i[help_link bridge_link] } } }],
|
39
39
|
["Roles", :roles,
|
40
|
-
{ path: { view: :
|
40
|
+
{ path: { view: :content } }],
|
41
41
|
["Notifications", :follow],
|
42
42
|
["API", :account,
|
43
43
|
{ path: { view: :api_key,
|
data/set/all/account.rb
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
def among? ok_ids
|
16
16
|
ok_ids.any? do |ok_id|
|
17
17
|
ok_id == AnyoneID ||
|
18
|
-
(ok_id == AnyoneWithRoleID && all_enabled_roles.size > 1) ||
|
18
|
+
# (ok_id == AnyoneWithRoleID && all_enabled_roles.size > 1) ||
|
19
19
|
parties.member?(ok_id)
|
20
20
|
end
|
21
21
|
end
|
@@ -86,14 +86,11 @@ def enabled_roles_card
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def fetch_roles
|
89
|
-
[AnyoneSignedInID] +
|
89
|
+
[AnyoneSignedInID] + role_ids_from_role_member_cards
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
93
|
-
|
94
|
-
role_trait = fetch :roles
|
95
|
-
role_trait ? role_trait.item_ids : []
|
96
|
-
end
|
92
|
+
def role_ids_from_role_member_cards
|
93
|
+
Self::Role.role_ids id
|
97
94
|
end
|
98
95
|
|
99
96
|
event :generate_token do
|
data/set/right/account/events.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#### ON CREATE
|
2
2
|
|
3
3
|
event :set_default_salt, :prepare_to_validate, on: :create do
|
4
|
-
|
4
|
+
field(:salt).generate
|
5
5
|
end
|
6
6
|
|
7
7
|
event :set_default_status, :prepare_to_validate, on: :create do
|
8
|
-
|
8
|
+
field :status, content: (accounted&.try(:default_account_status) || "active")
|
9
9
|
end
|
10
10
|
|
11
11
|
# ON UPDATE
|
@@ -47,7 +47,7 @@ end
|
|
47
47
|
# NOTE: this only works in the context of an action.
|
48
48
|
# if run independently, it will not activate an account
|
49
49
|
event :activate_account do
|
50
|
-
|
50
|
+
field :status, content: "active"
|
51
51
|
trigger_event! :send_welcome_email
|
52
52
|
end
|
53
53
|
|
data/set/right/account/views.rb
CHANGED
data/set/right/account.rb
CHANGED
@@ -21,9 +21,7 @@ end
|
|
21
21
|
|
22
22
|
# allow account owner to update account field content
|
23
23
|
def ok_to_update
|
24
|
-
|
25
|
-
|
26
|
-
super
|
24
|
+
(own_account? && !name_changed? && !type_id_changed?) || super
|
27
25
|
end
|
28
26
|
|
29
27
|
def changes_visible? act
|
data/set/right/email.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
include_set Abstract::AccountField
|
4
4
|
|
5
|
+
assign_type :phrase
|
6
|
+
|
5
7
|
event :validate_email, :validate, on: :save do
|
6
8
|
return unless content?
|
7
9
|
|
@@ -31,7 +33,7 @@ event :downcase_email, :prepare_to_validate, on: :save do
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def email_required?
|
34
|
-
!left
|
36
|
+
!left&.left&.codename == :wagn_bot
|
35
37
|
end
|
36
38
|
|
37
39
|
def ok_to_read
|
data/set/right/password.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
include_set Abstract::AccountField
|
2
2
|
|
3
|
+
assign_type :phrase
|
4
|
+
|
3
5
|
def history?
|
4
6
|
false
|
5
7
|
end
|
@@ -8,10 +10,7 @@ def ok_to_read
|
|
8
10
|
own_account? || super
|
9
11
|
end
|
10
12
|
|
11
|
-
event :encrypt_password, :store,
|
12
|
-
on: :save, changed: :content,
|
13
|
-
when: proc { !Card::Env[:no_password_encryptions] } do
|
14
|
-
# no_password_encryptions = hack for import - fix with api for ignoring events
|
13
|
+
event :encrypt_password, :store, on: :save, changed: :content do
|
15
14
|
salt = left&.salt
|
16
15
|
self.content = Auth.encrypt content, salt
|
17
16
|
|
data/set/right/roles.rb
CHANGED
@@ -1,27 +1,9 @@
|
|
1
|
-
|
2
|
-
return unless (fr = forbidden_roles).present?
|
1
|
+
assign_type :search_type
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
"#{fr.map(&:name).to_sentence}" # LOCALIZE
|
3
|
+
def virtual?
|
4
|
+
new?
|
7
5
|
end
|
8
6
|
|
9
|
-
def
|
10
|
-
|
11
|
-
with_old_role_permissions do |new_roles|
|
12
|
-
new_roles.reject do |card|
|
13
|
-
Card.fetch(card, "*members").ok? :update
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def with_old_role_permissions
|
19
|
-
new_roles = item_cards
|
20
|
-
new_content = content
|
21
|
-
left.clear_roles
|
22
|
-
Auth.update_always_cache nil
|
23
|
-
self.content = db_content_before_act
|
24
|
-
yield new_roles
|
25
|
-
ensure
|
26
|
-
self.content = new_content
|
7
|
+
def cql_content
|
8
|
+
{ member: "_left" }
|
27
9
|
end
|
data/set/right/salt.rb
CHANGED
data/set/right/status.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
include_set Abstract::AccountField
|
2
|
-
include_set Abstract::
|
2
|
+
include_set Abstract::List
|
3
|
+
|
4
|
+
assign_type :phrase
|
3
5
|
|
4
6
|
format :html do
|
5
7
|
def input_type
|
@@ -8,7 +10,7 @@ format :html do
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def option_names
|
11
|
-
%w[unapproved unverified active blocked system
|
13
|
+
%w[unapproved unverified active blocked] # system
|
12
14
|
end
|
13
15
|
|
14
16
|
def ok_to_update
|
data/set/self/role.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class << self
|
2
|
+
CACHE_KEY = "ROLEHASH".freeze
|
3
|
+
|
4
|
+
def load_rolehash
|
5
|
+
::Card.cache.fetch(CACHE_KEY) do
|
6
|
+
generate_rolehash
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate_rolehash
|
11
|
+
Auth.as_bot do
|
12
|
+
Card.search(left: { type_id: Card::RoleID }, right_id: Card::MembersID)
|
13
|
+
.each_with_object({}) do |member_card, hash|
|
14
|
+
hash[member_card.left_id] = ::Set.new member_card.item_ids
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_rolehash role_id, member_ids
|
20
|
+
role_hash[role_id] = member_ids
|
21
|
+
::Card.cache.write CACHE_KEY, role_hash
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear_rolehash
|
25
|
+
@role_hash = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def role_hash
|
29
|
+
@role_hash ||= load_rolehash
|
30
|
+
end
|
31
|
+
|
32
|
+
def role_ids user_id
|
33
|
+
role_hash.each_with_object([]) do |(role_id, member_ids), all_role_ids|
|
34
|
+
next unless member_ids.include? user_id
|
35
|
+
all_role_ids << role_id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/set/self/signin.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
# authentication event
|
10
10
|
event :signin, :validate, on: :update do
|
11
|
-
authenticate_or_abort
|
11
|
+
authenticate_or_abort field_content(:email), field_content(:password)
|
12
12
|
end
|
13
13
|
|
14
14
|
# abort after successful signin (do not save card)
|
@@ -30,8 +30,8 @@ event :send_reset_password_token, before: :signin, on: :update, trigger: :requir
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
@
|
33
|
+
def email_from_field
|
34
|
+
@email_from_field ||= field_content(:email)
|
35
35
|
end
|
36
36
|
|
37
37
|
def ok_to_read
|
@@ -76,7 +76,7 @@ def account_for email
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def send_reset_password_email_or_fail
|
79
|
-
if (account = account_for
|
79
|
+
if (account = account_for email_from_field)&.active?
|
80
80
|
send_reset_password_email account
|
81
81
|
else
|
82
82
|
reset_password_fail account
|
@@ -84,7 +84,7 @@ def send_reset_password_email_or_fail
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def blank_email?
|
87
|
-
return false if
|
87
|
+
return false if email_from_field.present?
|
88
88
|
|
89
89
|
error_on :email, :error_blank
|
90
90
|
end
|
@@ -151,8 +151,12 @@ format :html do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
view :signin_buttons do
|
154
|
+
class_up "button-form-group", "signin-buttons justify-content-between"
|
154
155
|
button_formgroup do
|
155
|
-
[
|
156
|
+
[
|
157
|
+
wrap_with("div", class: "pe-2") { [signin_button, signup_link] },
|
158
|
+
reset_password_link
|
159
|
+
]
|
156
160
|
end
|
157
161
|
end
|
158
162
|
|
@@ -186,10 +190,9 @@ format :html do
|
|
186
190
|
end
|
187
191
|
|
188
192
|
def reset_password_link
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
raw("<div style='float:right'>#{link}</div>")
|
193
|
+
link_to_view :edit, t(:account_reset_password),
|
194
|
+
path: { slot: { hide: :bridge_link } },
|
195
|
+
class: "btn btn-secondary btn-reset-password"
|
193
196
|
end
|
194
197
|
|
195
198
|
def edit_view_hidden
|
data/set/type/role.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
card_accessor :members
|
2
|
+
|
1
3
|
def disabled?
|
2
4
|
Auth.current&.fetch(:disabled_roles)&.item_ids&.include? id
|
3
5
|
end
|
@@ -9,7 +11,7 @@ format :html do
|
|
9
11
|
|
10
12
|
def role_checkbox
|
11
13
|
name = card.disabled? ? "add_item" : "drop_item"
|
12
|
-
subformat(Auth.current.field(:disabled_roles
|
14
|
+
subformat(Auth.current.field(:disabled_roles)).card_form :update do
|
13
15
|
[check_box_tag(name, card.id, !card.disabled?, class: "_edit-item"),
|
14
16
|
render_link]
|
15
17
|
end
|
data/set/type/signup/views.rb
CHANGED
@@ -3,7 +3,7 @@ format :html do
|
|
3
3
|
Auth.signed_in? && card.can_approve?
|
4
4
|
end
|
5
5
|
|
6
|
-
view :new do
|
6
|
+
view :new, cache: :never do
|
7
7
|
voo.title = invitation? ? t(:account_invite) : t(:account_sign_up)
|
8
8
|
super()
|
9
9
|
end
|
@@ -12,7 +12,7 @@ format :html do
|
|
12
12
|
[account_formgroups, (card.structure ? edit_slot : "")].join
|
13
13
|
end
|
14
14
|
|
15
|
-
view :new_buttons do
|
15
|
+
view :new_buttons, cache: :never do
|
16
16
|
button_formgroup do
|
17
17
|
[standard_create_button, invite_button].compact
|
18
18
|
end
|
@@ -24,7 +24,7 @@ format :html do
|
|
24
24
|
button_tag "Send Invitation", situation: "primary"
|
25
25
|
end
|
26
26
|
|
27
|
-
view :core, template: :haml do
|
27
|
+
view :core, template: :haml, cache: :never do
|
28
28
|
@lines = [signup_line] + account_lines
|
29
29
|
@body = process_content _render_raw
|
30
30
|
end
|
data/set/type/signup.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
include_set Abstract::Accountable
|
2
2
|
|
3
|
+
basket[:non_createable_types] << :signup
|
4
|
+
|
3
5
|
require_field :account
|
4
6
|
|
5
7
|
def default_account_status
|
@@ -26,7 +28,7 @@ event :approve_without_verification, :validate, on: :update, trigger: :required
|
|
26
28
|
# TODO: if validated here, add trigger and activate in storage phase
|
27
29
|
approvable do
|
28
30
|
activate_accounted
|
29
|
-
|
31
|
+
field(:account).activate_account
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -36,8 +38,8 @@ event :act_as_current_for_integrate_stage, :integrate, on: :create do
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def request_verification
|
39
|
-
acct =
|
40
|
-
acct.
|
41
|
+
acct = field :account
|
42
|
+
acct.field :status, content: "unverified"
|
41
43
|
acct.trigger_event! :send_verification_email
|
42
44
|
end
|
43
45
|
|
data/set/type/user.rb
CHANGED
@@ -3,7 +3,9 @@ include_set Abstract::Accountable
|
|
3
3
|
attr_accessor :email
|
4
4
|
|
5
5
|
format :html do
|
6
|
-
|
6
|
+
delegate :needs_setup?, to: Card::Auth
|
7
|
+
|
8
|
+
view :setup, unknown: true, perms: :needs_setup? do
|
7
9
|
with_nest_mode :edit do
|
8
10
|
voo.title = "Your deck is ready to go!" # LOCALIZE
|
9
11
|
voo.show! :help
|
@@ -41,6 +43,7 @@ format :html do
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
46
|
+
# FIXME. use trigger
|
44
47
|
def setup?
|
45
48
|
Card::Env.params[:setup]
|
46
49
|
end
|
@@ -54,8 +57,10 @@ event :setup_as_bot, before: :check_permissions, on: :create, when: :setup? do
|
|
54
57
|
end
|
55
58
|
|
56
59
|
event :setup_first_user, :prepare_to_store, on: :create, when: :setup? do
|
57
|
-
subcard
|
58
|
-
|
60
|
+
subcard %i[signup_alert_email to].cardname, content: name
|
61
|
+
roles_for_first_user.each do |role|
|
62
|
+
subcard [role, :members], content: name
|
63
|
+
end
|
59
64
|
end
|
60
65
|
|
61
66
|
def roles_for_first_user
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-account
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,56 +18,84 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.105.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
28
|
+
version: 1.105.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: card-mod-email
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.15.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.15.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: card-mod-permissions
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - '='
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 0.15.0
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - '='
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.15.0
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: card-mod-list
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - '='
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 0.
|
63
|
+
version: 0.15.0
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - '='
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 0.
|
70
|
+
version: 0.15.0
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: card-mod-integrate
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.15.0
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.15.0
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: card-mod-edit
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.15.0
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 0.15.0
|
71
99
|
description: ''
|
72
100
|
email:
|
73
101
|
- info@decko.org
|
@@ -76,6 +104,9 @@ extensions: []
|
|
76
104
|
extra_rdoc_files: []
|
77
105
|
files:
|
78
106
|
- README.md
|
107
|
+
- assets/style/account.scss
|
108
|
+
- data/real.yml
|
109
|
+
- db/migrate_core_cards/20220815112551_move_roles.rb
|
79
110
|
- locales/de.yml
|
80
111
|
- locales/en.yml
|
81
112
|
- set/abstract/account_field.rb
|
@@ -89,6 +120,7 @@ files:
|
|
89
120
|
- set/right/roles.rb
|
90
121
|
- set/right/salt.rb
|
91
122
|
- set/right/status.rb
|
123
|
+
- set/self/role.rb
|
92
124
|
- set/self/signin.rb
|
93
125
|
- set/type/role.rb
|
94
126
|
- set/type/signup.rb
|
@@ -96,6 +128,7 @@ files:
|
|
96
128
|
- set/type/signup/views.rb
|
97
129
|
- set/type/user.rb
|
98
130
|
- set/type/user/setup_help.haml
|
131
|
+
- set/type_plus_right/role/members.rb
|
99
132
|
- set/type_plus_right/user/email.rb
|
100
133
|
homepage: https://decko.org
|
101
134
|
licenses:
|
@@ -107,6 +140,7 @@ metadata:
|
|
107
140
|
wiki_uri: https://decko.org
|
108
141
|
documentation_url: http://docs.decko.org/
|
109
142
|
card-mod: account
|
143
|
+
card-mod-group: gem-defaults
|
110
144
|
post_install_message:
|
111
145
|
rdoc_options: []
|
112
146
|
require_paths:
|
@@ -122,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
156
|
- !ruby/object:Gem::Version
|
123
157
|
version: '0'
|
124
158
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
159
|
+
rubygems_version: 3.3.11
|
126
160
|
signing_key:
|
127
161
|
specification_version: 4
|
128
162
|
summary: Email-based account handling for decko cards
|