Commit Graph

12620 Commits

Author SHA1 Message Date
Hannah Wolfe
e30b9735fa Added staff user limit
refs: https://github.com/TryGhost/Team/issues/510

- In the case that host config is provided, keep staff users within the limiti
- The definition of a staff user is a user with a role other than Contributor, and whose status is not inactive
   - Contributors don't count
   - Suspended (status inactive) users don't count
   - Locked users DO count
   - Invited users DO count
- You can't invite more staff users whilst there are pending invites
- You can't unsuspend a user, or change the role on a user in such a way as will take you over your limit
- You can't import staff users - all imported users are automatically set to Contributors
- As part of this work, we are changing the default Ghost user to a Contributor otherwise it uses up a staff user

Note: there is one known active bug with this commit.
- Assume you have one remaining user within your limit. You send an invite, this works.
- You cannot "resend" that invite, it will think you're sending a new invite and hit the limit
- You must "revoke" that invite first, and create a new one
- This bug exists because the resend function uses the add endpoint & does a delete+add, but this hits the permission check before the delete
2021-03-04 16:13:04 +00:00
Hannah Wolfe
7e2da2adee Update dependency @tryghost/limit-service to v1.2.0
- The new version ensures that invites are counted when looking for staff users
2021-03-04 13:56:32 +00:00
Daniel Lockyer
4e18606942
Updated logging messages in migration commands
no issue

- by switching around the the columns and tables, it becomes a
  lot easier to read the log line in a natural order
2021-03-04 13:53:06 +00:00
Sam Lord
ae090b0a13 Update to latest Ghost Ignition
no issue
2021-03-04 12:10:32 +00:00
Hannah Wolfe
26f56626ce Updated host config to correctly use camelCase
refs https://github.com/TryGhost/Team/issues/510

- When the host config was introduced it was incorrectly introduced as host_settings instead of hostSettings
- All other Ghost config uses camelCase, so changing this now before it becomes a problem
- Note: Also removed some rogue return awaits that don't make sense. It's not possible to hit that case, but cleaning up anyway
2021-03-04 11:39:32 +00:00
Hannah Wolfe
84e5bdc46a Fixed accent color on pages with no context
refs: refs 74fe765410

- Some pages, like error pages have no context.
- In that case there is also no previous style or script tag and so the existingScriptIndex is -1, not 0/falsy :D
- This ensures we always add this style tag
2021-03-04 10:56:53 +00:00
Naz
4ac5feaa0a Fixed webhook model unit test 2021-03-04 10:56:58 +01:00
Naz
38fbfe0bde Added note about missing migration for itegration_id 2021-03-04 10:56:58 +01:00
Naz
f57115d3cc Fixed fixture creation order in webhooks tests
- The tests need to have 'integrations' as a first fixture created so that webhooks can relate to an integration
2021-03-04 10:56:58 +01:00
Naz
cc0a655a3d Fixed data generator crating webhooks linked to intergrations
- This is needed to prevent FK failures
2021-03-04 10:56:58 +01:00
Thibaut Patel
e52dc87b7c Added a foreign key from webhooks to integrations
issue https://github.com/TryGhost/Team/issues/477
2021-03-04 10:56:58 +01:00
Daniel Lockyer
2d47ddb400
Updated lockfile 2021-03-04 09:26:01 +00:00
Naz
9995ae3616 Added support for locale key in Admin Settings API
refs https://github.com/TryGhost/Team/issues/509

- Allows to update and read 'locale' key along with the deprecated 'lang'
- In Ghost v5 the 'lang' key will be dropped and the migration in settings table will clean up the key name to match the one exposed through the APIs
2021-03-04 21:20:46 +13:00
Naz
7a11a9b3c4 Bumped gscan to 4.0.0-pre.5
refs https://github.com/TryGhost/Team/issues/509

- Updated version includes {{@site.lang}} deprecation
2021-03-04 21:18:27 +13:00
Naz
07254edfe3 Fixed cache test suite
refs 41c93f982d

- The public settings hash was "turned around" so that the object keys are now identified by "keys" on "values"
2021-03-04 18:35:02 +13:00
Naz
41c93f982d Added 'locale' property to public settings
refs https://github.com/TryGhost/Team/issues/509

- During 3.x we standardised on "lang" instead of "default_locale" for the site setting, which was an assumption based on an earlier change to @site.lang to make <html lang="@site.lang"> read nicer. This was a mistake as the field represents more than "lang" its a "locale". With this changeset we introduce a transition to use "locale" name for the value instead of "lang"
- Adds `@site.locale" value in as well as new 'locale' property in Content API's response
- "lang" will be considered as deprecated starting with API v4 and will be dropped completely with API v5
2021-03-04 16:00:02 +13:00
Naz
e133c45314 Cleaned up public settings test suite
refs https://github.com/TryGhost/Team/issues/509
refs c2a3297f5d

- Before introducing new public setting made sure the test is up to date and checks everything it was intended to.
2021-03-04 15:41:49 +13:00
Naz
c2a3297f5d Restructured public settings cache hash
refs https://github.com/TryGhost/Team/issues/509

- Flipping around key/newKey pair allows to map multiple keys to the same field in the settings
- This becomes handy when there's a need to deprecate a field. For example, we are about to introduce a 'locale' setting which would need to map to 'lang' db key, with current structure it's impossible to have many:1 mapping because it's impossible to have duplicate keys in the JS object ("hash")
2021-03-04 15:24:08 +13:00
Naz
2e2d185087 Added note to webhooks.api_version column
refs https://github.com/TryGhost/Team/issues/513
refs https://github.com/TryGhost/Team/issues/477

- We have skipped work to improve the 'defaultTo' value when working on Ghost 4.0 release, so adding this comment while context loaded
-  defaultTo should not be set to anything as it leads to more maintenance work during major version bump
- having validation might make sense but could lead to similar maintenance work unless it's linked to some global nosion of "supported API versions" used everywhere
2021-03-04 13:09:31 +13:00
Naz
e7e5f0ad15 Updated API versions used in regression test for webhooks
refs https://github.com/TryGhost/Team/issues/513

- Tests confused versions after doing a "tripplication"
- Extracted a global "API_VERSION" variable for each suite to make api version used in the test explicit
2021-03-04 13:06:16 +13:00
Naz
55e9ef957f Fixed typo 2021-03-04 11:27:31 +13:00
Naz
4778fce615 Reordered API exports to improve readability
refs https://github.com/TryGhost/Team/issues/513

- Having exports in no particular order was making it hard to spot if there's anything missing
- Having a DESC order on the exported API versions makes it very easy to modify and maintain in the future
2021-03-04 11:27:09 +13:00
Hannah Wolfe
edb626af18 Added custom integration feature limit
refs: https://github.com/TryGhost/Team/issues/510

- in the case that host config is provided, prevents the creation of custom integrations
2021-03-03 20:15:49 +00:00
Rish
cb43a8e3a8 Updated fixture for test theme to use @site
no refs
refs b56e684258

The test theme fixture was using old `@blog`  helper which was deprecated in v2 and replaced with `@site`. Since the latest bump to Gscan - b56e684258 - now validates a theme by going through nested `*.hbs` files, this was missed so far as it didn't fail the tests. This commit updates the test theme fixture to use updated value.
2021-03-04 01:09:54 +05:30
Rish
b56e684258 Bumped gscan to 4.0.0-pre.4
refs https://github.com/TryGhost/Team/issues/492

- updates regex that checks valid files to test rules against to include all *.hbs files
- cleans up rules for last4 and currency_symbol helpers
2021-03-03 23:43:08 +05:30
Hannah Wolfe
8f4e43a1fe Update dependency @tryghost/limit-service to v1.1.1
- fixes a really weird unexpected token = error when using lodash templates in Ghost
- this was caused by _.templateSettings being global
- this fix ensures that the config of the limit-service stays in the limit-service!
2021-03-03 17:58:38 +00:00
Sam Lord
40da54f123 Updated Ghost-Ignition to latest version 2021-03-03 17:47:56 +00:00
Peter Zimon
a1aa18e5b2 Minor email copy updates 2021-03-03 17:42:28 +01:00
Peter Zimon
3064addcb5 Refined email template spacings 2021-03-03 17:34:35 +01:00
Peter Zimon
f71cc4e7b0 Updated email styles
- updated welcome, password reset and invitation email styles to match with 4.0 changes
2021-03-03 17:15:37 +01:00
Hannah Wolfe
b310666bda Added custom theme feature limit
refs: https://github.com/TryGhost/Team/issues/510

- in the case that host config is provided, limits Ghost to only permitting official themes to be installed and used
2021-03-03 14:25:19 +00:00
Hannah Wolfe
c7b843471f Added limit service
refs: https://github.com/TryGhost/Team/issues/510

- added and wired up the new limit service, which is a lazy-loaded service
- this handles the case that there are host limits set in config, and wraps all the logic needed for detecting exceeded limits & throwing limit errors
- expects limits to be set in config under `host_settings.limits`
- supported limits are managed in the limit service, outside of core
2021-03-03 13:43:05 +00:00
Daniel Lockyer
5de7f2d3fe
Added regenerated lockfile 2021-03-03 13:31:55 +00:00
Peter Zimon
e0da433122 Added 'icon' to site API endpoint
- added 'icon' to site API response as Admin should access it on sign in screen
2021-03-03 13:49:44 +01:00
Rish
b70537461b Bumped gscan to 4.0.0-pre.2
refs https://github.com/TryGhost/Team/issues/492

Adds new warnings/recommendation for `foreach` , `default_payment_card_last4` and `currency_symbol` to v3/v4
2021-03-03 18:18:30 +05:30
Renovate Bot
e872d3e6be
Update dependency @tryghost/helpers to v1.1.39 2021-03-03 10:00:49 +00:00
Thibaut Patel
126f9004b4 Updated a duplicate migration id
no issue
2021-03-03 10:45:21 +01:00
Thibaut Patel
8b7d7ba1f1 Fixed the add/drop foreign key on sqlite
issue https://github.com/TryGhost/Ghost/pull/12713
ref https://github.com/knex/knex/issues/4155
2021-03-03 10:35:10 +01:00
Thibaut Patel
0843ab6a37 Added 'on delete cascade' to several foreign keys in sqlite
issue https://github.com/TryGhost/Team/issues/476
blocked by https://github.com/TryGhost/Ghost/pull/12702
2021-03-03 10:35:10 +01:00
Fabien 'egg' O'Carroll
b7a092a24a
🐛 Stopped Ghost crashing when sending bulk emails (#12718)
refs https://github.com/TryGhost/Ghost/issues/12610
refs https://github.com/mailgun/mailgun-js-boland/blob/v0.22.0/lib/request.js#L285-L333

The mailgun domain is used by the mailgun API to construct the URL for
the API. e.g for a domain of "mg.example.com" the URL for the API
messages would look like:

https://api.mailgun.net/v3/mg.example.com/messages

One weird thing about the mailgun API is that if the path does not map
to an API endpoint, then instead of a 404, we get a 200, with a body of
"Mailgun Magnificent API".

The `mailgun-js` library which we use, expects a JSON response, and will
return a body of undefined if it does not get one.

This all resulted in us trying to read the property `id` of an undefined
`body` variable. The fix here is to reject the containing Promise, if
there is no body. So that the default error handling will kick in.
2021-03-03 09:34:44 +00:00
Daniel Lockyer
2ca8e56187
Updated knex-migrator dependency to 4.0.1 2021-03-03 08:47:21 +00:00
Renovate Bot
84313cef49 Update dependency knex to v0.21.19 2021-03-03 08:29:36 +00:00
Kevin Ansfield
1cc3f35043 Fixed accent color not updating in front-end preview
refs https://github.com/TryGhost/Ghost/pull/12717

- preview data is set on `options.data.site` so we need to read from that rather than directly from the settings cache
2021-03-03 08:00:41 +00:00
Naz
476d4389c6 Bumped scheduler to use v4 API
refs https://github.com/TryGhost/Team/issues/513

- The bump does not effect scheduled post as URL with authentication token is generated during runtime for DefaultScheduler.
- This needs to be checked for SchedulerAdapter implementations which use persistant storage
2021-03-03 18:45:41 +13:00
Naz
9fab028621 Added missing v4 API endpoints mount
refs ff6d31e08f
refs https://github.com/TryGhost/Team/issues/513

- The API was missing from the referenced commit when v3 was being extracted
2021-03-03 18:44:00 +13:00
Naz
f68cf109dd Bumped default API version to v4 in url-utils
refs https://github.com/TryGhost/Team/issues/513

- Bumping as this is now a default API
2021-03-03 17:26:55 +13:00
Naz
d37a4ec97e Bumped url-utils to 1.0.0
refs https://github.com/TryGhost/Team/issues/513

- The `defaultApiVersion` parameter was bumped to v4 in this version
- Also contains a refactore for `url.parse` method which was used for base url detection
2021-03-03 17:19:31 +13:00
Naz
f09216efde Changed api:versions config for v4 to point to v4 API link
refs a551970315
refs https://github.com/TryGhost/Team/issues/513

- This setting is used in url-utils (b17a965c88/core/shared/url-utils.js (L7)) which would create a `canary/admin` for `v4` with previous configuration. The links should link to one's explicit version if available, not to an alias like 'canary'
2021-03-03 15:42:04 +13:00
Naz
b17a965c88 Switched members services to use v4 API
refs https://github.com/TryGhost/Team/issues/513

- Bumping version as this is now the latest stable API.
- The change might cause this particular side effect (acceptable for major version): if a member requests a login URL when the instance is on 3.x version and site owner upgrades do 4.x before member authenticates through login link, the login will fail and the member will have to request a new login URL.
2021-03-03 14:42:03 +13:00
Naz
e2f997d43b Fixed API version used to call mega's addEmail
refs d5cf0fc03e (diff-e36a1dec6b39d9ac36e1676236700e57b6f32d4e089c7183928b95b9c8daca4bL198)

- The changes was an overlooked version missmatch, should have been a 'canary' value
2021-03-03 13:16:25 +13:00