trek 2.5.0 → 2.7.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/.node-version +1 -1
- data/AGENTS.md +18 -14
- data/CHANGELOG.md +88 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +135 -124
- data/Makefile +9 -1
- data/README.md +17 -21
- data/app/components/trek/dashboard/tile_component/tile_component.css +9 -0
- data/app/components/trek/dashboard/tile_component/tile_component.html.slim +4 -2
- data/app/components/trek/dashboard/tile_component.rb +12 -2
- data/app/components/trek/form/content_editor_component/content_editor_component.css +9 -8
- data/app/components/trek/form/content_editor_component/content_editor_component.html.slim +19 -93
- data/app/components/trek/form/content_editor_component/content_editor_component.js +94 -251
- data/app/components/trek/form/content_editor_component/extensions/block_view.js +40 -0
- data/app/components/trek/form/content_editor_component/extensions/image_block.js +28 -26
- data/app/components/trek/form/content_editor_component/extensions/prompts_block.js +15 -26
- data/app/components/trek/form/content_editor_component/extensions/table_of_contents.js +1 -3
- data/app/components/trek/form/content_editor_component.rb +15 -0
- data/app/components/trek/form/image_field_component/image_field_component.css +40 -1
- data/app/components/trek/form/image_field_component/image_field_component.html.slim +0 -9
- data/app/components/trek/form/image_field_component/image_field_component.js +1 -2
- data/app/components/trek/form/image_field_component.rb +36 -9
- data/app/components/trek/form/password_strength_component/password_strength_component.css +2 -0
- data/app/components/trek/form/sound_field_component/sound_field_component.js +1 -2
- data/app/components/trek/security_check_component/security_check_component.css +69 -0
- data/app/components/trek/security_check_component/security_check_component.html.slim +19 -0
- data/app/components/trek/security_check_component/security_check_component.js +15 -0
- data/app/components/trek/security_check_component.rb +19 -0
- data/app/content/trek/content/cleaner.rb +53 -0
- data/app/content/trek/content/document.rb +2 -2
- data/app/content/trek/content/list_item.rb +1 -1
- data/app/content/trek/content/paragraph.rb +7 -2
- data/app/content/trek/content/prompts_block.rb +1 -2
- data/app/content/trek/content.rb +6 -0
- data/app/controllers/concerns/trek/auditable.rb +5 -2
- data/app/controllers/concerns/trek/localization.rb +6 -2
- data/app/controllers/concerns/trek/reorderable.rb +24 -6
- data/app/controllers/trek/csp_reports_controller.rb +14 -1
- data/app/controllers/trek/panels/prompts_controller.rb +1 -1
- data/app/controllers/trek/resource_controller.rb +5 -5
- data/app/jobs/trek/purge_expired_sessions_job.rb +4 -3
- data/app/jobs/trek/purge_expired_sign_in_codes_job.rb +15 -0
- data/app/models/concerns/trek/contentable.rb +15 -1
- data/app/models/concerns/trek/users/sign_in_code.rb +70 -0
- data/app/models/concerns/trek/users/sign_in_lockout.rb +4 -2
- data/app/policies/trek/security_check_policy.rb +8 -0
- data/app/uploaders/image_uploader.rb +77 -15
- data/app/views/trek/panels/links/_form.html.slim +2 -4
- data/app/views/trek/panels/prompts/create.turbo_stream.slim +0 -1
- data/config/locales/trek.en.yml +97 -11
- data/config/locales/trek.fr.yml +97 -11
- data/docs/.vitepress/config.mjs +5 -1
- data/docs/background-jobs.md +74 -0
- data/docs/content-editor.md +219 -0
- data/docs/customize.md +2 -0
- data/docs/deploy.md +69 -6
- data/docs/getting-started.md +16 -18
- data/docs/index.md +2 -2
- data/docs/personal-data.md +61 -0
- data/docs/proxies.md +2 -2
- data/docs/reference/components.md +4 -4
- data/docs/reference/concerns/contentable.md +10 -4
- data/docs/reference/concerns/formattable.md +1 -1
- data/docs/reference/concerns/fragmentable.md +12 -6
- data/docs/reference/concerns/orderable.md +2 -2
- data/docs/reference/concerns/search-engine-optimizable.md +1 -1
- data/docs/reference/concerns/searchable.md +14 -1
- data/docs/reference/concerns/sectionable.md +7 -3
- data/docs/reference/concerns/versionable.md +1 -1
- data/docs/reference/controllers.md +33 -1
- data/docs/reference/environment-variables.md +3 -2
- data/docs/reference/formatters.md +4 -31
- data/docs/reference/forms.md +7 -4
- data/docs/reference/generators/admin-user.md +1 -1
- data/docs/reference/generators/audit-log.md +12 -13
- data/docs/reference/generators/install.md +23 -11
- data/docs/reference/generators/public-accounts.md +159 -0
- data/docs/reference/generators/scaffold.md +28 -9
- data/docs/reference/generators/security-headers.md +5 -4
- data/docs/reference/generators/taxonomies.md +1 -1
- data/docs/reference/icons.md +5 -3
- data/docs/reference/index.md +10 -7
- data/docs/reference/models/current.md +5 -3
- data/docs/reference/models/page-version.md +1 -1
- data/docs/reference/models/user.md +7 -8
- data/docs/reference/uploaders.md +25 -0
- data/docs/reference/validators.md +1 -1
- data/docs/security.md +30 -9
- data/docs/what-is-trek.md +4 -4
- data/lib/generators/trek/USAGE +1 -1
- data/lib/generators/trek/audit_log_generator.rb +62 -0
- data/lib/generators/trek/helpers.rb +17 -0
- data/lib/generators/trek/install/admin/routes_generator.rb +2 -1
- data/lib/generators/trek/install/admin/security_check_generator.rb +36 -0
- data/lib/generators/trek/install/admin/users_generator.rb +6 -1
- data/lib/generators/trek/install/audit_log_generator.rb +9 -45
- data/lib/generators/trek/install/ci_generator.rb +19 -0
- data/lib/generators/trek/install/good_job_generator.rb +161 -0
- data/lib/generators/trek/install/model_specs_generator.rb +3 -3
- data/lib/generators/trek/install/postcss_generator.rb +1 -2
- data/lib/generators/trek/install/ruby_generator.rb +1 -1
- data/lib/generators/trek/install/scalingo_generator.rb +7 -45
- data/lib/generators/trek/install/translations_generator.rb +1 -2
- data/lib/generators/trek/install_generator.rb +18 -2
- data/lib/generators/trek/public_accounts_generator.rb +294 -0
- data/lib/generators/trek/scaffold_generator.rb +22 -21
- data/lib/generators/trek/scalingo_generator.rb +67 -0
- data/lib/generators/trek/templates/.gitlab-ci.yml +10 -1
- data/lib/generators/trek/templates/AGENTS.md +2 -2
- data/lib/generators/trek/templates/Makefile +1 -0
- data/lib/generators/trek/templates/config/i18n-tasks.yml.erb +0 -8
- data/lib/generators/trek/templates/controllers/admin/password_renewals_controller.rb +11 -0
- data/lib/generators/trek/templates/controllers/admin/security_checks_controller.rb +11 -0
- data/lib/generators/trek/templates/controllers/admin/user_sessions_controller.rb +1 -1
- data/lib/generators/trek/templates/controllers/admin/users_controller.rb +0 -8
- data/lib/generators/trek/templates/controllers/concerns/trek/authentication.rb +13 -4
- data/lib/generators/trek/templates/initializers/content_security_policy.rb +3 -2
- data/lib/generators/trek/templates/initializers/good_job.rb.tt +40 -0
- data/lib/generators/trek/templates/jobs/mail_delivery_job.rb +6 -0
- data/lib/generators/trek/templates/layouts/admin.html.slim +10 -0
- data/lib/generators/trek/templates/mailers/admin_mailer.rb +4 -2
- data/lib/generators/trek/templates/package.json.tt +1 -1
- data/lib/generators/trek/templates/policies/security_check.rb +4 -0
- data/lib/generators/trek/templates/public_accounts/api/authentication.rb.tt +76 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/accounts_controller.rb.tt +22 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/active_sessions_controller.rb.tt +21 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/base_controller.rb.tt +71 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/email_changes_controller.rb.tt +55 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/email_confirmations_controller.rb.tt +19 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/password_resets_controller.rb.tt +28 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/passwords_controller.rb.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/registrations_controller.rb.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/sessions_controller.rb.tt +57 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/sign_in_codes_controller.rb.tt +20 -0
- data/lib/generators/trek/templates/public_accounts/jobs/sign_in_code_job.rb.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/locales/accounts.en.yml.tt +215 -0
- data/lib/generators/trek/templates/public_accounts/locales/accounts.fr.yml.tt +215 -0
- data/lib/generators/trek/templates/public_accounts/mailers/account_mailer.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/migrations/create_accounts.rb.tt +46 -0
- data/lib/generators/trek/templates/public_accounts/models/account/session.rb.tt +47 -0
- data/lib/generators/trek/templates/public_accounts/models/account/sign_in_code.rb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/models/account.rb.tt +87 -0
- data/lib/generators/trek/templates/public_accounts/spec/api/accounts_spec.rb.tt +90 -0
- data/lib/generators/trek/templates/public_accounts/spec/api/sign_ins_spec.rb.tt +188 -0
- data/lib/generators/trek/templates/public_accounts/spec/models/account/sign_in_code_spec.rb.tt +66 -0
- data/lib/generators/trek/templates/public_accounts/spec/models/account_spec.rb.tt +129 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/accounts_spec.rb.tt +126 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/authentication_spec.rb.tt +43 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/sign_ins_spec.rb.tt +237 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.fr.html.slim.tt +13 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.en.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.en.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.fr.html.slim.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.fr.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.fr.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.fr.html.slim.tt +13 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.en.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.en.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.fr.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.fr.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.en.html.slim.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.en.text.erb.tt +14 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.fr.html.slim.tt +24 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.fr.text.erb.tt +14 -0
- data/lib/generators/trek/templates/public_accounts/web/authentication.rb.tt +97 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/accounts_controller.rb.tt +33 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/active_sessions_controller.rb.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/base_controller.rb.tt +52 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/email_changes_controller.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/email_confirmations_controller.rb.tt +19 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/password_resets_controller.rb.tt +41 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/passwords_controller.rb.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/registrations_controller.rb.tt +24 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/sessions_controller.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/sign_in_codes_controller.rb.tt +32 -0
- data/lib/generators/trek/templates/public_accounts/web/views/_flash.html.slim.tt +5 -0
- data/lib/generators/trek/templates/public_accounts/web/views/accounts/show.html.slim.tt +52 -0
- data/lib/generators/trek/templates/public_accounts/web/views/email_changes/edit.html.slim.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/web/views/email_changes/new.html.slim.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/views/password_resets/edit.html.slim.tt +29 -0
- data/lib/generators/trek/templates/public_accounts/web/views/password_resets/new.html.slim.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/views/passwords/edit.html.slim.tt +28 -0
- data/lib/generators/trek/templates/public_accounts/web/views/registrations/new.html.slim.tt +30 -0
- data/lib/generators/trek/templates/public_accounts/web/views/sessions/new.html.slim.tt +40 -0
- data/lib/generators/trek/templates/public_accounts/web/views/sign_in_codes/new.html.slim.tt +17 -0
- data/lib/generators/trek/templates/spec/jobs/mail_delivery_job_spec.rb +11 -0
- data/lib/generators/trek/templates/spec/mailers/admin_mailer_spec.rb +10 -0
- data/lib/generators/trek/templates/spec/requests/admin/fragments_spec.rb +1 -1
- data/lib/generators/trek/templates/spec/requests/admin/good_job_spec.rb +34 -0
- data/lib/generators/trek/templates/spec/requests/admin/pages_spec.rb +12 -1
- data/lib/generators/trek/templates/spec/requests/admin/panels_spec.rb +16 -0
- data/lib/generators/trek/templates/spec/requests/admin/password_renewal_spec.rb +2 -2
- data/lib/generators/trek/templates/spec/requests/admin/security_checks_spec.rb +24 -0
- data/lib/generators/trek/templates/spec/requests/admin/sign_in_lockout_spec.rb +1 -1
- data/lib/generators/trek/templates/spec/requests/admin/sign_in_notices_spec.rb +33 -0
- data/lib/generators/trek/templates/spec/requests/admin/user_sessions_spec.rb +2 -2
- data/lib/generators/trek/templates/views/admin/pages/_form.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin/security_checks/show.html.slim +9 -0
- data/lib/generators/trek/templates/views/admin/user_password_resets/edit.html.slim +6 -1
- data/lib/generators/trek/templates/views/admin/user_sessions/new.html.slim +4 -1
- data/lib/generators/trek/templates/views/admin/users/index.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.en.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.en.text.erb +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.fr.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.fr.text.erb +1 -1
- data/lib/tasks/trek/attachments.rake +12 -0
- data/lib/tasks/trek/security.rake +10 -0
- data/lib/trek/csp_reports.rb +22 -4
- data/lib/trek/disposable_email_domains.rb +9 -20
- data/lib/trek/engine.rb +5 -0
- data/lib/trek/json_compatibility.rb +20 -0
- data/lib/trek/security_check.rb +241 -0
- data/lib/trek/stored_image_metadata.rb +88 -0
- data/lib/trek/typography_formatter.rb +35 -4
- data/lib/trek/version.rb +1 -1
- data/lib/trek.rb +2 -1
- data/package.json +16 -13
- data/postcss.config.js +0 -3
- data/trek.gemspec +6 -7
- data/vitest.config.mjs +24 -0
- data/yarn.lock +1667 -1010
- metadata +122 -33
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
en:
|
|
2
|
+
activerecord:
|
|
3
|
+
attributes:
|
|
4
|
+
<%= file_name %>:
|
|
5
|
+
email: Email
|
|
6
|
+
name: Name
|
|
7
|
+
<% if password? -%>
|
|
8
|
+
password: Password
|
|
9
|
+
unconfirmed_email: New email
|
|
10
|
+
errors:
|
|
11
|
+
models:
|
|
12
|
+
<%= file_name %>:
|
|
13
|
+
attributes:
|
|
14
|
+
password:
|
|
15
|
+
common: is among the most common passwords, choose a less predictable one
|
|
16
|
+
digit_and_symbol: must contain a digit and a symbol, unless it is at least %{count} characters long
|
|
17
|
+
personal: must not contain your name or email
|
|
18
|
+
pwned: appears in known data breaches, choose another one
|
|
19
|
+
sequence: must not contain a sequence such as 12345, azerty or aaaaa
|
|
20
|
+
<% end -%>
|
|
21
|
+
models:
|
|
22
|
+
<%= file_name %>:
|
|
23
|
+
one: <%= human_name %>
|
|
24
|
+
other: <%= human_name.pluralize %>
|
|
25
|
+
<%= file_name %>_mailer:
|
|
26
|
+
<% if code? -%>
|
|
27
|
+
email_change_code:
|
|
28
|
+
subject: Confirm your new email address
|
|
29
|
+
sign_in_code:
|
|
30
|
+
subject: Your sign-in code
|
|
31
|
+
<% else -%>
|
|
32
|
+
email_change:
|
|
33
|
+
subject: Confirm your new email address
|
|
34
|
+
email_confirmation:
|
|
35
|
+
subject: Confirm your email address
|
|
36
|
+
password_reset:
|
|
37
|
+
subject: Choose a new password
|
|
38
|
+
sign_in_locked:
|
|
39
|
+
subject: Signing in to your account is paused
|
|
40
|
+
<% end -%>
|
|
41
|
+
<% unless model_only? -%>
|
|
42
|
+
<%= accounts_path %>:
|
|
43
|
+
<% if api? -%>
|
|
44
|
+
api:
|
|
45
|
+
errors:
|
|
46
|
+
email_taken: This email is already used by another account.
|
|
47
|
+
invalid: Some fields are invalid.
|
|
48
|
+
<% if code? -%>
|
|
49
|
+
invalid_code: This code is wrong or expired. Check the last email, or ask for a new code.
|
|
50
|
+
<% end -%>
|
|
51
|
+
invalid_email: Enter a valid email address.
|
|
52
|
+
<% if password? -%>
|
|
53
|
+
invalid_password: Wrong email or password.
|
|
54
|
+
invalid_token: This link is wrong or expired. Ask for a new one.
|
|
55
|
+
<% end -%>
|
|
56
|
+
rate_limited: Too many attempts. Try again in a few minutes.
|
|
57
|
+
recent_sign_in_needed: For your security, sign in again to continue.
|
|
58
|
+
sign_in_needed: Sign in to continue.
|
|
59
|
+
<% else -%>
|
|
60
|
+
accounts:
|
|
61
|
+
destroy:
|
|
62
|
+
success: Your account is deleted.
|
|
63
|
+
show:
|
|
64
|
+
change_email: Change
|
|
65
|
+
<% if password? -%>
|
|
66
|
+
change_password: Change your password
|
|
67
|
+
<% end -%>
|
|
68
|
+
delete: Delete my account
|
|
69
|
+
delete_confirm: Delete your account for good?
|
|
70
|
+
delete_intro: Your account and everything attached to it are deleted for good.
|
|
71
|
+
delete_title: Delete your account
|
|
72
|
+
<% if password? -%>
|
|
73
|
+
pending_email: "%{email} will replace it once you follow the link we sent there."
|
|
74
|
+
resend_confirmation: Send the confirmation link again
|
|
75
|
+
<% end -%>
|
|
76
|
+
save: Save
|
|
77
|
+
sessions: Signed-in browsers
|
|
78
|
+
sign_out: Sign out
|
|
79
|
+
sign_out_others: Sign out of all other browsers
|
|
80
|
+
sign_out_session: Sign out
|
|
81
|
+
signed_in: signed in on %{date}
|
|
82
|
+
this_browser: "(this browser)"
|
|
83
|
+
title: Your account
|
|
84
|
+
<% if password? -%>
|
|
85
|
+
unconfirmed: This email isn't confirmed yet. Follow the link we sent to it.
|
|
86
|
+
<% end -%>
|
|
87
|
+
update:
|
|
88
|
+
success: Your account is saved.
|
|
89
|
+
active_sessions:
|
|
90
|
+
destroy:
|
|
91
|
+
success: The browser is signed out.
|
|
92
|
+
destroy_others:
|
|
93
|
+
success: The other browsers are signed out.
|
|
94
|
+
authentication:
|
|
95
|
+
rate_limited: Too many attempts. Try again in a few minutes.
|
|
96
|
+
recent_sign_in_needed: For your security, sign in again to continue.
|
|
97
|
+
sign_in_needed: Sign in to continue.
|
|
98
|
+
email_changes:
|
|
99
|
+
create:
|
|
100
|
+
invalid_email: Enter a valid email address, other than your current one.
|
|
101
|
+
<% if code? -%>
|
|
102
|
+
sent: We sent a code to %{email}.
|
|
103
|
+
edit:
|
|
104
|
+
back: Back to your account
|
|
105
|
+
code: Code
|
|
106
|
+
intro: Enter the code we sent to %{email}.
|
|
107
|
+
submit: Confirm
|
|
108
|
+
title: Confirm your new email
|
|
109
|
+
<% else -%>
|
|
110
|
+
sent: We sent a link to %{email}. Your email changes once you follow it.
|
|
111
|
+
<% end -%>
|
|
112
|
+
new:
|
|
113
|
+
back: Back to your account
|
|
114
|
+
email: New email
|
|
115
|
+
<% if code? -%>
|
|
116
|
+
intro: We'll send a code to the new address to confirm it's yours.
|
|
117
|
+
submit: Send me a code
|
|
118
|
+
<% else -%>
|
|
119
|
+
intro: We'll send a link to the new address to confirm it's yours.
|
|
120
|
+
submit: Send me a link
|
|
121
|
+
<% end -%>
|
|
122
|
+
title: Change your email
|
|
123
|
+
<% if code? -%>
|
|
124
|
+
update:
|
|
125
|
+
failure: This code is wrong or expired.
|
|
126
|
+
success: Your email is changed.
|
|
127
|
+
taken: This email is already used by another account.
|
|
128
|
+
<% else -%>
|
|
129
|
+
show:
|
|
130
|
+
invalid: This link is wrong or expired. Ask for a new one from your account.
|
|
131
|
+
success: Your email is changed.
|
|
132
|
+
taken: This email is already used by another account.
|
|
133
|
+
email_confirmations:
|
|
134
|
+
create:
|
|
135
|
+
sent: We sent a confirmation link to %{email}.
|
|
136
|
+
show:
|
|
137
|
+
invalid: This link is wrong or expired. Ask for a new one from your account.
|
|
138
|
+
success: Your email is confirmed.
|
|
139
|
+
password_resets:
|
|
140
|
+
create:
|
|
141
|
+
sent: If this email has an account, we sent it a link to choose a new password.
|
|
142
|
+
edit:
|
|
143
|
+
rules: At least %{min} characters, with a digit and a symbol unless it is at least %{passphrase} characters long.
|
|
144
|
+
submit: Save
|
|
145
|
+
title: Choose a new password
|
|
146
|
+
invalid: This link is wrong or expired. Ask for a new one.
|
|
147
|
+
new:
|
|
148
|
+
intro: Enter your email. We'll send you a link to choose a new password.
|
|
149
|
+
sign_in: Back to signing in
|
|
150
|
+
submit: Send me a link
|
|
151
|
+
title: Forgot your password?
|
|
152
|
+
update:
|
|
153
|
+
success: Your password is saved. Sign in with it.
|
|
154
|
+
passwords:
|
|
155
|
+
edit:
|
|
156
|
+
back: Back to your account
|
|
157
|
+
intro: At least %{min} characters, with a digit and a symbol unless it is at least %{passphrase} characters long.
|
|
158
|
+
submit: Save
|
|
159
|
+
title: Your password
|
|
160
|
+
update:
|
|
161
|
+
success: Your password is saved. Your other browsers are signed out.
|
|
162
|
+
registrations:
|
|
163
|
+
create:
|
|
164
|
+
success: Welcome! We sent a link to %{email} to confirm it.
|
|
165
|
+
new:
|
|
166
|
+
rules: At least %{min} characters, with a digit and a symbol unless it is at least %{passphrase} characters long.
|
|
167
|
+
sign_in: I already have an account
|
|
168
|
+
submit: Sign up
|
|
169
|
+
title: Create your account
|
|
170
|
+
<% end -%>
|
|
171
|
+
sessions:
|
|
172
|
+
create:
|
|
173
|
+
<% if code? -%>
|
|
174
|
+
failure: This code is wrong or expired. Check the last email, or ask for a new code.
|
|
175
|
+
<% else -%>
|
|
176
|
+
failure: Wrong email or password.
|
|
177
|
+
<% end -%>
|
|
178
|
+
success: You're signed in.
|
|
179
|
+
destroy:
|
|
180
|
+
success: You're signed out.
|
|
181
|
+
new:
|
|
182
|
+
<% if code? -%>
|
|
183
|
+
code: Code
|
|
184
|
+
<% if invite_only? -%>
|
|
185
|
+
intro: If %{email} has an account, we sent it a 6-digit code. It is valid for %{validity}.
|
|
186
|
+
<% else -%>
|
|
187
|
+
intro: We sent a 6-digit code to %{email}. It is valid for %{validity}.
|
|
188
|
+
<% end -%>
|
|
189
|
+
other_email: Use another email
|
|
190
|
+
submit: Sign in
|
|
191
|
+
title: Enter your code
|
|
192
|
+
<% else -%>
|
|
193
|
+
forgot_password: Forgot your password?
|
|
194
|
+
sign_up: Create an account
|
|
195
|
+
submit: Sign in
|
|
196
|
+
title: Sign in
|
|
197
|
+
<% end -%>
|
|
198
|
+
<% if code? -%>
|
|
199
|
+
sign_in_codes:
|
|
200
|
+
create:
|
|
201
|
+
invalid_email: Enter a valid email address.
|
|
202
|
+
<% if invite_only? -%>
|
|
203
|
+
sent: If %{email} has an account, a code has just been sent to it.
|
|
204
|
+
new:
|
|
205
|
+
intro: Enter your email. If it has an account, we'll send you a code to sign in.
|
|
206
|
+
<% else -%>
|
|
207
|
+
sent: We sent a code to %{email}.
|
|
208
|
+
new:
|
|
209
|
+
intro: Enter your email. We'll send you a code to sign in, or to create your account if you don't have one yet.
|
|
210
|
+
<% end -%>
|
|
211
|
+
submit: Send me a code
|
|
212
|
+
title: Sign in
|
|
213
|
+
<% end -%>
|
|
214
|
+
<% end -%>
|
|
215
|
+
<% end -%>
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
fr:
|
|
2
|
+
activerecord:
|
|
3
|
+
attributes:
|
|
4
|
+
<%= file_name %>:
|
|
5
|
+
email: Adresse e-mail
|
|
6
|
+
name: Nom
|
|
7
|
+
<% if password? -%>
|
|
8
|
+
password: Mot de passe
|
|
9
|
+
unconfirmed_email: Nouvelle adresse e-mail
|
|
10
|
+
errors:
|
|
11
|
+
models:
|
|
12
|
+
<%= file_name %>:
|
|
13
|
+
attributes:
|
|
14
|
+
password:
|
|
15
|
+
common: fait partie des mots de passe les plus courants, choisissez-en un moins prévisible
|
|
16
|
+
digit_and_symbol: doit contenir un chiffre et un caractère spécial, sauf s'il fait au moins %{count} caractères
|
|
17
|
+
personal: ne doit pas contenir votre nom ni votre adresse e-mail
|
|
18
|
+
pwned: figure dans des fuites de données connues, choisissez-en un autre
|
|
19
|
+
sequence: ne doit pas contenir de suite comme 12345, azerty ou aaaaa
|
|
20
|
+
<% end -%>
|
|
21
|
+
models:
|
|
22
|
+
<%= file_name %>:
|
|
23
|
+
one: <%= human_name %>
|
|
24
|
+
other: <%= human_name.pluralize %>
|
|
25
|
+
<%= file_name %>_mailer:
|
|
26
|
+
<% if code? -%>
|
|
27
|
+
email_change_code:
|
|
28
|
+
subject: Confirmez votre nouvelle adresse e-mail
|
|
29
|
+
sign_in_code:
|
|
30
|
+
subject: Votre code de connexion
|
|
31
|
+
<% else -%>
|
|
32
|
+
email_change:
|
|
33
|
+
subject: Confirmez votre nouvelle adresse e-mail
|
|
34
|
+
email_confirmation:
|
|
35
|
+
subject: Confirmez votre adresse e-mail
|
|
36
|
+
password_reset:
|
|
37
|
+
subject: Choisissez un nouveau mot de passe
|
|
38
|
+
sign_in_locked:
|
|
39
|
+
subject: La connexion à votre compte est suspendue
|
|
40
|
+
<% end -%>
|
|
41
|
+
<% unless model_only? -%>
|
|
42
|
+
<%= accounts_path %>:
|
|
43
|
+
<% if api? -%>
|
|
44
|
+
api:
|
|
45
|
+
errors:
|
|
46
|
+
email_taken: Cette adresse e-mail est déjà utilisée par un autre compte.
|
|
47
|
+
invalid: Certains champs ne sont pas valides.
|
|
48
|
+
<% if code? -%>
|
|
49
|
+
invalid_code: Ce code est erroné ou expiré. Vérifiez le dernier e-mail, ou demandez un nouveau code.
|
|
50
|
+
<% end -%>
|
|
51
|
+
invalid_email: Saisissez une adresse e-mail valide.
|
|
52
|
+
<% if password? -%>
|
|
53
|
+
invalid_password: Adresse e-mail ou mot de passe incorrect.
|
|
54
|
+
invalid_token: Ce lien est erroné ou expiré. Demandez-en un nouveau.
|
|
55
|
+
<% end -%>
|
|
56
|
+
rate_limited: Trop de tentatives. Réessayez dans quelques minutes.
|
|
57
|
+
recent_sign_in_needed: Pour votre sécurité, reconnectez-vous pour continuer.
|
|
58
|
+
sign_in_needed: Connectez-vous pour continuer.
|
|
59
|
+
<% else -%>
|
|
60
|
+
accounts:
|
|
61
|
+
destroy:
|
|
62
|
+
success: Votre compte est supprimé.
|
|
63
|
+
show:
|
|
64
|
+
change_email: Changer
|
|
65
|
+
<% if password? -%>
|
|
66
|
+
change_password: Changer votre mot de passe
|
|
67
|
+
<% end -%>
|
|
68
|
+
delete: Supprimer mon compte
|
|
69
|
+
delete_confirm: Supprimer votre compte définitivement ?
|
|
70
|
+
delete_intro: Votre compte et tout ce qui y est rattaché sont supprimés définitivement.
|
|
71
|
+
delete_title: Supprimer votre compte
|
|
72
|
+
<% if password? -%>
|
|
73
|
+
pending_email: "%{email} la remplacera une fois le lien envoyé à cette adresse suivi."
|
|
74
|
+
resend_confirmation: Renvoyer le lien de confirmation
|
|
75
|
+
<% end -%>
|
|
76
|
+
save: Enregistrer
|
|
77
|
+
sessions: Navigateurs connectés
|
|
78
|
+
sign_out: Se déconnecter
|
|
79
|
+
sign_out_others: Déconnecter tous les autres navigateurs
|
|
80
|
+
sign_out_session: Déconnecter
|
|
81
|
+
signed_in: connecté le %{date}
|
|
82
|
+
this_browser: "(ce navigateur)"
|
|
83
|
+
title: Votre compte
|
|
84
|
+
<% if password? -%>
|
|
85
|
+
unconfirmed: Cette adresse n'est pas encore confirmée. Suivez le lien que nous y avons envoyé.
|
|
86
|
+
<% end -%>
|
|
87
|
+
update:
|
|
88
|
+
success: Votre compte est enregistré.
|
|
89
|
+
active_sessions:
|
|
90
|
+
destroy:
|
|
91
|
+
success: Le navigateur est déconnecté.
|
|
92
|
+
destroy_others:
|
|
93
|
+
success: Les autres navigateurs sont déconnectés.
|
|
94
|
+
authentication:
|
|
95
|
+
rate_limited: Trop de tentatives. Réessayez dans quelques minutes.
|
|
96
|
+
recent_sign_in_needed: Pour votre sécurité, reconnectez-vous pour continuer.
|
|
97
|
+
sign_in_needed: Connectez-vous pour continuer.
|
|
98
|
+
email_changes:
|
|
99
|
+
create:
|
|
100
|
+
invalid_email: Saisissez une adresse e-mail valide, autre que l'actuelle.
|
|
101
|
+
<% if code? -%>
|
|
102
|
+
sent: Nous avons envoyé un code à %{email}.
|
|
103
|
+
edit:
|
|
104
|
+
back: Retour à votre compte
|
|
105
|
+
code: Code
|
|
106
|
+
intro: Saisissez le code envoyé à %{email}.
|
|
107
|
+
submit: Confirmer
|
|
108
|
+
title: Confirmez votre nouvelle adresse
|
|
109
|
+
<% else -%>
|
|
110
|
+
sent: Nous avons envoyé un lien à %{email}. Votre adresse changera une fois ce lien suivi.
|
|
111
|
+
<% end -%>
|
|
112
|
+
new:
|
|
113
|
+
back: Retour à votre compte
|
|
114
|
+
email: Nouvelle adresse e-mail
|
|
115
|
+
<% if code? -%>
|
|
116
|
+
intro: Nous enverrons un code à la nouvelle adresse pour confirmer qu'elle est bien à vous.
|
|
117
|
+
submit: Recevoir un code
|
|
118
|
+
<% else -%>
|
|
119
|
+
intro: Nous enverrons un lien à la nouvelle adresse pour confirmer qu'elle est bien à vous.
|
|
120
|
+
submit: Recevoir un lien
|
|
121
|
+
<% end -%>
|
|
122
|
+
title: Changer votre adresse e-mail
|
|
123
|
+
<% if code? -%>
|
|
124
|
+
update:
|
|
125
|
+
failure: Ce code est erroné ou expiré.
|
|
126
|
+
success: Votre adresse e-mail est changée.
|
|
127
|
+
taken: Cette adresse e-mail est déjà utilisée par un autre compte.
|
|
128
|
+
<% else -%>
|
|
129
|
+
show:
|
|
130
|
+
invalid: Ce lien est erroné ou expiré. Demandez-en un nouveau depuis votre compte.
|
|
131
|
+
success: Votre adresse e-mail est changée.
|
|
132
|
+
taken: Cette adresse e-mail est déjà utilisée par un autre compte.
|
|
133
|
+
email_confirmations:
|
|
134
|
+
create:
|
|
135
|
+
sent: Nous avons envoyé un lien de confirmation à %{email}.
|
|
136
|
+
show:
|
|
137
|
+
invalid: Ce lien est erroné ou expiré. Demandez-en un nouveau depuis votre compte.
|
|
138
|
+
success: Votre adresse e-mail est confirmée.
|
|
139
|
+
password_resets:
|
|
140
|
+
create:
|
|
141
|
+
sent: Si cette adresse a un compte, nous lui avons envoyé un lien pour choisir un nouveau mot de passe.
|
|
142
|
+
edit:
|
|
143
|
+
rules: Au moins %{min} caractères, avec un chiffre et un caractère spécial s'il fait moins de %{passphrase} caractères.
|
|
144
|
+
submit: Enregistrer
|
|
145
|
+
title: Choisissez un nouveau mot de passe
|
|
146
|
+
invalid: Ce lien est erroné ou expiré. Demandez-en un nouveau.
|
|
147
|
+
new:
|
|
148
|
+
intro: Saisissez votre adresse e-mail. Nous vous enverrons un lien pour choisir un nouveau mot de passe.
|
|
149
|
+
sign_in: Retour à la connexion
|
|
150
|
+
submit: Recevoir un lien
|
|
151
|
+
title: Mot de passe oublié ?
|
|
152
|
+
update:
|
|
153
|
+
success: Votre mot de passe est enregistré. Connectez-vous avec.
|
|
154
|
+
passwords:
|
|
155
|
+
edit:
|
|
156
|
+
back: Retour à votre compte
|
|
157
|
+
intro: Au moins %{min} caractères, avec un chiffre et un caractère spécial s'il fait moins de %{passphrase} caractères.
|
|
158
|
+
submit: Enregistrer
|
|
159
|
+
title: Votre mot de passe
|
|
160
|
+
update:
|
|
161
|
+
success: Votre mot de passe est enregistré. Vos autres navigateurs sont déconnectés.
|
|
162
|
+
registrations:
|
|
163
|
+
create:
|
|
164
|
+
success: Bienvenue ! Nous avons envoyé un lien à %{email} pour la confirmer.
|
|
165
|
+
new:
|
|
166
|
+
rules: Au moins %{min} caractères, avec un chiffre et un caractère spécial s'il fait moins de %{passphrase} caractères.
|
|
167
|
+
sign_in: J'ai déjà un compte
|
|
168
|
+
submit: Créer mon compte
|
|
169
|
+
title: Créer votre compte
|
|
170
|
+
<% end -%>
|
|
171
|
+
sessions:
|
|
172
|
+
create:
|
|
173
|
+
<% if code? -%>
|
|
174
|
+
failure: Ce code est erroné ou expiré. Vérifiez le dernier e-mail, ou demandez un nouveau code.
|
|
175
|
+
<% else -%>
|
|
176
|
+
failure: Adresse e-mail ou mot de passe incorrect.
|
|
177
|
+
<% end -%>
|
|
178
|
+
success: Vous êtes connecté.
|
|
179
|
+
destroy:
|
|
180
|
+
success: Vous êtes déconnecté.
|
|
181
|
+
new:
|
|
182
|
+
<% if code? -%>
|
|
183
|
+
code: Code
|
|
184
|
+
<% if invite_only? -%>
|
|
185
|
+
intro: Si %{email} a un compte, nous lui avons envoyé un code à 6 chiffres. Il est valable %{validity}.
|
|
186
|
+
<% else -%>
|
|
187
|
+
intro: Nous avons envoyé un code à 6 chiffres à %{email}. Il est valable %{validity}.
|
|
188
|
+
<% end -%>
|
|
189
|
+
other_email: Utiliser une autre adresse
|
|
190
|
+
submit: Se connecter
|
|
191
|
+
title: Saisissez votre code
|
|
192
|
+
<% else -%>
|
|
193
|
+
forgot_password: Mot de passe oublié ?
|
|
194
|
+
sign_up: Créer un compte
|
|
195
|
+
submit: Se connecter
|
|
196
|
+
title: Se connecter
|
|
197
|
+
<% end -%>
|
|
198
|
+
<% if code? -%>
|
|
199
|
+
sign_in_codes:
|
|
200
|
+
create:
|
|
201
|
+
invalid_email: Saisissez une adresse e-mail valide.
|
|
202
|
+
<% if invite_only? -%>
|
|
203
|
+
sent: Si %{email} a un compte, nous venons de lui envoyer un code.
|
|
204
|
+
new:
|
|
205
|
+
intro: Saisissez votre adresse e-mail. Si elle a un compte, nous vous enverrons un code pour vous connecter.
|
|
206
|
+
<% else -%>
|
|
207
|
+
sent: Nous avons envoyé un code à %{email}.
|
|
208
|
+
new:
|
|
209
|
+
intro: Saisissez votre adresse e-mail. Nous vous enverrons un code pour vous connecter, ou pour créer votre compte si vous n'en avez pas encore.
|
|
210
|
+
<% end -%>
|
|
211
|
+
submit: Recevoir un code
|
|
212
|
+
title: Se connecter
|
|
213
|
+
<% end -%>
|
|
214
|
+
<% end -%>
|
|
215
|
+
<% end -%>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
class <%= class_name %>Mailer < ApplicationMailer
|
|
2
|
+
include ActionView::Helpers::DateHelper
|
|
3
|
+
<% if code? -%>
|
|
4
|
+
|
|
5
|
+
# The code to sign in with: to an email that may have no account yet.
|
|
6
|
+
def sign_in_code(email, code)
|
|
7
|
+
@code = code
|
|
8
|
+
@validity = distance_of_time_in_words(0, <%= class_name %>::SignInCode.validity)
|
|
9
|
+
|
|
10
|
+
mail to: email
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The code confirming a new email address for an account, sent to that address.
|
|
14
|
+
def email_change_code(email, code)
|
|
15
|
+
@code = code
|
|
16
|
+
@validity = distance_of_time_in_words(0, <%= class_name %>::SignInCode.validity)
|
|
17
|
+
|
|
18
|
+
mail to: email
|
|
19
|
+
end
|
|
20
|
+
<% else -%>
|
|
21
|
+
|
|
22
|
+
# The link confirming the email given on signing up. Its token is made here, in the job sending
|
|
23
|
+
# the email, rather than in the request.
|
|
24
|
+
def email_confirmation(<%= file_name %>)
|
|
25
|
+
@<%= file_name %> = <%= file_name %>
|
|
26
|
+
@url = link_to_confirm(<%= file_name %>.generate_token_for(:email_confirmation))
|
|
27
|
+
@validity = distance_of_time_in_words(0, <%= class_name %>.token_definitions[:email_confirmation].expires_in)
|
|
28
|
+
|
|
29
|
+
mail to: <%= file_name %>.email
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# The link to choose a new password; nothing is sent to an email without an account.
|
|
33
|
+
def password_reset(<%= file_name %>)
|
|
34
|
+
@<%= file_name %> = <%= file_name %>
|
|
35
|
+
@url = link_to_reset(<%= file_name %>.password_reset_token)
|
|
36
|
+
@validity = distance_of_time_in_words(0, <%= class_name %>.token_definitions[:password_reset].expires_in)
|
|
37
|
+
|
|
38
|
+
mail to: <%= file_name %>.email
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The link confirming a new email (unconfirmed_email), sent to that address.
|
|
42
|
+
def email_change(<%= file_name %>)
|
|
43
|
+
@<%= file_name %> = <%= file_name %>
|
|
44
|
+
@url = link_to_change_email(<%= file_name %>.generate_token_for(:email_change))
|
|
45
|
+
@validity = distance_of_time_in_words(0, <%= class_name %>.token_definitions[:email_change].expires_in)
|
|
46
|
+
|
|
47
|
+
mail to: <%= file_name %>.unconfirmed_email
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Signing in is locked after failed tries in a row (Trek::Users::SignInLockout): the
|
|
51
|
+
# <%= human_name.downcase %> waits, resets the password, or learns someone may be guessing it.
|
|
52
|
+
def sign_in_locked(<%= file_name %>)
|
|
53
|
+
@<%= file_name %> = <%= file_name %>
|
|
54
|
+
<% if web? -%>
|
|
55
|
+
@reset_url = new_<%= route_prefix %>_password_reset_url
|
|
56
|
+
<% end -%>
|
|
57
|
+
|
|
58
|
+
mail to: <%= file_name %>.email
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
<% if model_only? -%>
|
|
64
|
+
# The app's own sign-in handles these links: a page of the site, or the mobile app opening them (iOS
|
|
65
|
+
# universal links, Android app links). They point at the app's domain, or at <%= accounts_path.upcase %>_APP_LINKS_URL.
|
|
66
|
+
<% elsif api? -%>
|
|
67
|
+
# The mobile app opens these links (iOS universal links, Android app links) and sends their token
|
|
68
|
+
# to the API. They point at the app's domain, or at <%= accounts_path.upcase %>_APP_LINKS_URL.
|
|
69
|
+
<% end -%>
|
|
70
|
+
<% unless web? -%>
|
|
71
|
+
def link_to_confirm(token) = app_link("account/confirm", token)
|
|
72
|
+
def link_to_reset(token) = app_link("password-reset", token)
|
|
73
|
+
def link_to_change_email(token) = app_link("account/email", token)
|
|
74
|
+
|
|
75
|
+
def app_link(path, token)
|
|
76
|
+
base = ENV.fetch("<%= accounts_path.upcase %>_APP_LINKS_URL") { "https://#{default_url_options.fetch(:host)}<%= "/#{options[:path]}" if options[:path].present? %>" }
|
|
77
|
+
"#{base}/#{path}?#{{ token: }.to_query}"
|
|
78
|
+
end
|
|
79
|
+
<% else -%>
|
|
80
|
+
def link_to_confirm(token) = <%= route_prefix %>_email_confirmation_url(token:)
|
|
81
|
+
def link_to_reset(token) = edit_<%= route_prefix %>_password_reset_url(token:)
|
|
82
|
+
def link_to_change_email(token) = <%= route_prefix %>_email_change_url(token:)
|
|
83
|
+
<% end -%>
|
|
84
|
+
<% end -%>
|
|
85
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class TrekCreate<%= class_name.pluralize %> < <%= migration_class_name %>
|
|
2
|
+
def change
|
|
3
|
+
create_table :<%= table_name %> do |t|
|
|
4
|
+
t.string :email, null: false, index: { unique: true }
|
|
5
|
+
t.string :name
|
|
6
|
+
<% if password? -%>
|
|
7
|
+
t.string :password_digest, null: false
|
|
8
|
+
t.integer :failed_sign_in_count, null: false, default: 0
|
|
9
|
+
t.datetime :sign_in_locked_until
|
|
10
|
+
# When the email was confirmed by its link; nil until then
|
|
11
|
+
t.datetime :confirmed_at
|
|
12
|
+
# A new email, until its link confirms it
|
|
13
|
+
t.string :unconfirmed_email
|
|
14
|
+
<% end -%>
|
|
15
|
+
# The last request, at most every 5 minutes, e.g. to delete the accounts nobody uses
|
|
16
|
+
t.datetime :last_activity_at, index: true
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
create_table :<%= file_name %>_sessions do |t|
|
|
22
|
+
t.belongs_to :<%= file_name %>, null: false, foreign_key: true
|
|
23
|
+
t.string :user_agent
|
|
24
|
+
t.string :ip_address
|
|
25
|
+
# The host name of the IP address (Trek::ReverseDns)
|
|
26
|
+
t.string :ip_hostname
|
|
27
|
+
t.datetime :last_activity_at, null: false
|
|
28
|
+
|
|
29
|
+
t.timestamps
|
|
30
|
+
end
|
|
31
|
+
<% if code? -%>
|
|
32
|
+
|
|
33
|
+
create_table :<%= file_name %>_sign_in_codes do |t|
|
|
34
|
+
t.string :email, null: false
|
|
35
|
+
t.string :purpose, null: false
|
|
36
|
+
t.belongs_to :<%= file_name %>, foreign_key: true
|
|
37
|
+
t.string :code_digest, null: false
|
|
38
|
+
t.integer :attempts, null: false, default: 0
|
|
39
|
+
t.datetime :expires_at, null: false, index: true
|
|
40
|
+
|
|
41
|
+
t.datetime :created_at, null: false
|
|
42
|
+
end
|
|
43
|
+
add_index :<%= file_name %>_sign_in_codes, %i[email purpose]
|
|
44
|
+
<% end -%>
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<% if api? -%>
|
|
2
|
+
# A device of the mobile app signed in as the <%= human_name.downcase %>, found through the JWT it sends
|
|
3
|
+
# (Authorization: Bearer). The token only names the session: signing out deletes the session, and the
|
|
4
|
+
# token stops working with it.
|
|
5
|
+
<% elsif model_only? -%>
|
|
6
|
+
# A signed-in <%= human_name.downcase %>: the app's own sign-in creates the session, finds it on each request
|
|
7
|
+
# (Current.<%= file_name %>_session) and deletes it on signing out.
|
|
8
|
+
<% else -%>
|
|
9
|
+
# A browser signed in as the <%= human_name.downcase %>, found through a signed <%= file_name %>_session_id cookie.
|
|
10
|
+
<% end -%>
|
|
11
|
+
class <%= class_name %>::Session < ApplicationRecord
|
|
12
|
+
# Expires after idle_timeout without a request, and lifetime after signing in; longer than the admin's.
|
|
13
|
+
include Trek::Users::SessionLifetime
|
|
14
|
+
self.idle_timeout = 30.days
|
|
15
|
+
self.lifetime = 1.year
|
|
16
|
+
|
|
17
|
+
# Changing the password or deleting the account needs a sign-in this recent.
|
|
18
|
+
RECENT = 15.minutes
|
|
19
|
+
|
|
20
|
+
belongs_to :<%= file_name %>
|
|
21
|
+
|
|
22
|
+
def recent?
|
|
23
|
+
created_at > RECENT.ago
|
|
24
|
+
end
|
|
25
|
+
<% if api? -%>
|
|
26
|
+
|
|
27
|
+
# Signed with a key of its own, derived from the app's secret_key_base.
|
|
28
|
+
TOKEN_ALGORITHM = "HS256".freeze
|
|
29
|
+
|
|
30
|
+
def self.token_key
|
|
31
|
+
Rails.application.key_generator.generate_key("<%= accounts_path %>/session_tokens")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# The session the token names, unless the token is forged or past the session's lifetime.
|
|
35
|
+
def self.from_token(token)
|
|
36
|
+
payload, = JWT.decode(token, token_key, true, algorithm: TOKEN_ALGORITHM)
|
|
37
|
+
find_by(id: payload["sub"])
|
|
38
|
+
rescue JWT::DecodeError
|
|
39
|
+
nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# The JWT the app keeps and sends with each request; it expires with the session's lifetime.
|
|
43
|
+
def token
|
|
44
|
+
JWT.encode({ sub: id, iat: created_at.to_i, exp: (created_at + lifetime).to_i }, self.class.token_key, TOKEN_ALGORITHM)
|
|
45
|
+
end
|
|
46
|
+
<% end -%>
|
|
47
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# A code emailed to sign in, or to confirm a new email address (Trek::Users::SignInCode): kept by
|
|
2
|
+
# email, as one is sent whether or not the email has an account.
|
|
3
|
+
class <%= class_name %>::SignInCode < ApplicationRecord
|
|
4
|
+
include Trek::Users::SignInCode
|
|
5
|
+
|
|
6
|
+
# The account changing its email to this one; nil when signing in.
|
|
7
|
+
belongs_to :<%= file_name %>, optional: true
|
|
8
|
+
end
|