* Promisify `AuthenticationController.doPassportLogin`
* Update tests `AuthenticationController.doPassportLogin`
* Add test on error handling for `AuthenticationController.doPassportLogin`
* Add test on error handling for `V1LoginController.doLogin`
* Extract error handling to `getErrorObject` function
* Simplify code
* Add `Metrics` calls
* Add `password is too long` in AuthenticationController
* Make `info` object consistent with the rest of the codebase
* Move error handling to `AuthenticationManager.handleAuthenticateErrors`
* Move `handleAuthenticateErrors` to other file
I moved this solely because I didn't manage to test it otherwise
* Update tests
* Remove `preDoPassportLogin` hook call
* Remove test on `preDoPassportLogin`
* Use try/catch block instead of `.catch()`
* Revert "Use try/catch block instead of `.catch()`"
This reverts commit 3475afa93ce4af7ad55c91bfc1d7ad3317600ea5.
* Replace `.catch` by `try/catch`
GitOrigin-RevId: 3fba65c30a2c5fc6e5abcd5b83c52801852ed462
* Replace `LoginRateLimiter.processLoginRequest` call by use of `RateLimiterMiddleware`
* Lowercase the email to avoid rate-limit bypass
* Remove unit test "when the users rate limit"
* Use `EmailHelper.parseEmail` to normalize email in `processLoginRequest`
This should address the `trim()` bypass
* Use `.trim().toLowerCase()` instead of `EmailHelper.parseEmail`
We can't use `EmailHelper.parseEmail`, else it breaks the test (and feature): "with username that does not look like an email"
* Add acceptance test for rate limit
* Add comment on rate limits
* Rename `rateLimiter` to `rateLimiterLoginEmail` for clarity
* Make the login rate limits configurable from the settings
GitOrigin-RevId: cf1c3a416745f2b007c85014a5084570d4a049a7
Link sharing changes events fixes for collaborator sharing-updates prompt and project open event
GitOrigin-RevId: 45449f0dd27e07de189a9c2620b0aa9a8849dc41
Allow checking permissions for all users on a project and rename checkPermissions -> AssertPermissions
GitOrigin-RevId: 511356cf2fe68367e284347e68e59f6116bd0f80
Implement link sharing warning events by reusing the StartFreeTrial paywall button component from the original modal
GitOrigin-RevId: 9c16407ad8a7b5afc9b5b13be1491ef903ae74a3
* Add getEditInviteCount to count only edit collaborators
* Add getInvitedEditCollaboratorCount to count joined editors
* Add canAddXEditCollaborators to determine if owner can add more editors
* Update setCollaboratorInfo to check if editor slots are available
GitOrigin-RevId: a88707f102dfbde39322f5a7bbc79d47b6e810d5
* Add helpers for checking and removing user readwrite token membership
* Add sharing-updates page and handlers
* Redirect read write token members to sharing-updates on project load
GitOrigin-RevId: d552a2cd74a9843c6103923b03f137131a48877a
* add RestoreFileOrigin in overleaf-editor-core
* support source to be an object
* use sourceOrOrigin as param
* rename to originOrSource so the priority is more clear
* get timestamp from version
* fix test
* include version and min_count in getUpdatesFromHistory
* extractOriginOrSource util function
* fix RestoreManagerTests
GitOrigin-RevId: 0ace05a6ade2794c753a9d0bffb4f858ecc6899a
* Promisify LdapController
* Update tests LdapControllerTests.js
* Promisify `AuthenticationController.finishLogin`
* Simplify null checks in LdapController
* Fix: don't use spread operator in module.exports
* Make `AuthenticationController.promises.finishLogin` a promise that resolves
* Fixup: `finishLogin` does not call `next` then the promise finishes, it calls it only on errors
* Use `Modules.promises.hooks.fire`
* Revert `processPassportLogin` callback style
* Update error handling: Use `OError.tag` instead of `logger.err`
* Fix unit tests: Rely on callbacks rather than promises
* Fix: Actually call `passport.authenticate` (!!)
* Update test: fixup `passport.authenticate` mocks
This would have caught the bugs that the previous commit is solving
* Remove `.then(() => next())` in `processPassportLogin`
Co-authored-by: Eric Mc Sween <eric.mcsween@overleaf.com>
---------
Co-authored-by: Eric Mc Sween <eric.mcsween@overleaf.com>
GitOrigin-RevId: a7eab5f5289956aeb8f2418408958daef3511ab7
* [web] revert binary file
* use addEntityWithName if file was deleted
* todo comments
* only show Revert file in ui even if deleted
* use _revertBinaryFile function
* emit new ids when reverting
* format:fix
* await emitToRoom calls
* use EditorController.upsertFile
* remove _revertBinaryFile function
* binary file check
* mock importFile method in tests
* move findElementByPath stub
* debug ci error
* resolve with empty object as file
* fix tests
* remove await before expect()
* format:fix
* test when binary file exists and when it does not
* use "file-revert" for source
* [web] revert existing file without ranges support (#18107)
* [web] revert existing file without ranges support
* ignore document_updated_externally if file-revert
* fix test
GitOrigin-RevId: a5e0c83a7635bc7d934dec9debe916bdd4beb51e
* Rename `RecurlyWrapper` to `promises`, as it will only contain the promises soon
* Update `apiRequest`
* Update `_parseXml`
* Update `_parseXmlAndGetAttribute`
* Update `_parse*Xml`
* Update `updateAccountEmailAddress`
* Update `checkAccountExists`
* Update `createAccount`
* Update `createBillingInfo`
* Update `setAddressAndCompanyBillingInfo`
* Update `createSubscription`
* Update `_createPaypalSubscription`
* Update `_handle422Response`
* Update `_createCreditCardSubscription`
* Update `createSubscription`
* Update `getSubscriptions`
* Update `getSubscription`
* Update `getPaginatedEndpoint`
* Update `getAccount`
* Update `getAccountActiveCoupons`
* Update `getCoupon`
* Update `getBillingInfo`
* Update `getAccountPastDueInvoices`
* Update `attemptInvoiceCollection`
* Update `updateSubscription`
* Update `createFixedAmmountCoupon`
* Update `lookupCoupon`
* Update `redeemCoupon`
* Update `extendTrial`
* Update `listAccountActiveSubscriptions`
* To find which functions to add as callbackified, I used this Regex:
`RecurlyWrapper\.(?!promises)[^.\s]*`
And after adding callbackified functions, we're left with no results with the Regex:
`RecurlyWrapper\.(?!promises|apiUrl|_buildXml|_parseXml|attemptInvoiceCollection|createFixedAmmountCoupon|getAccountActiveCoupons|getBillingInfo|getPaginatedEndpoint|getSubscription|updateAccountEmailAddress)[^.\s]*`
* Update unit tests
* Test `getSubscription` both as "promise" and as "callback"
I'm not sure if we want to generalize this.
* Fix: add missing `await`s (!!)
* Change `apiRequest` to reject errors instead of resolving it in an object
* Fixup for CollectPayPalPastDueInvoice test
* Fix: callbackify `getSubscriptions` (!!)
* Replace `.then(...)` chain by multiple `await`
* Fixup `attemptInvoicesCollection`: prevent reading length of undefined
* Use `return await` when returning promises
Per https://github.com/overleaf/internal/pull/18384#pullrequestreview-2065738771
GitOrigin-RevId: ceda755b24fd29f97a27e60ac5db9bc7e369f932
* Fix `revokeAllUserSessions` call in `_cleanupUser`
The user object should be passed, not the _id
* Change `revokeAllUserSessions` signature, take `req` and `stayLoggedIn` arguments
* Update uses of `revokeAllUserSessions`
* Fix promisified `revokeAllUserSessions` args
* Update tests
* Destroy or Regenerate the session in the end of `revokeAllUserSessions`
Per https://github.com/overleaf/internal/issues/17036#issuecomment-1938398570
* Revert "Destroy or Regenerate the session in the end of `revokeAllUserSessions`"
This reverts commit fe30734dbe45b27d2931d2e43a711d591bb85787.
* Rename `revokeAllUserSessions` to `removeSessionsFromRedis`
* Fixup tests
* Fix: add optional chaining in `req.sessionID` (!!)
GitOrigin-RevId: d41676bf00f463230af495e09c65fb9ee521f49f
Revert "Revert "[web] Store anonymous users split test assignments in new format in session""
GitOrigin-RevId: bd48a21c17df91eda1536378d8d999a1933e83a2
* Add a unit test on `SubscriptionFormatters.formatPrice`
* Add JSDoc to `formatPrice`
Also: Name the functions before exporting:
This fixes my IDE (WebStorm) navigation
* Make `'USD'` the default param instead of reassigning
* Create `formatCurrency` function
* Use `formatCurrency` in SubscriptionFormatters
* Use an `isNoCentsCurrency` logic for `CLP` `JPY` `KRW` `VND`
And remove custom `CLP` logic and locale
* Add `locale` param to `formatPrice`
* Generate `groups.json` and `localizedPlanPricing.json`
```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```
* Update scripts/plan-prices/plans.js to generate numbers instead of localized amounts
* Generate `groups.json` and `localizedPlanPricing.json`
```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```
* Remove generation of `plans.json`
As /services/web/frontend/js/main/plans.js was removed in https://github.com/overleaf/internal/pull/12593
* Sort currencies in alphabetical order in scripts/plan-prices/plans.js
* Generate `groups.json` and `localizedPlanPricing.json`
```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```
* Use `formatCurrency` in price-summary.tsx
* Use `formatCurrency` in Subscription Pug files
* Fix unit tests SubscriptionHelperTests.js
* Remove unused `currencySymbol`
* Change to `formatCurrency` in other React components
* Add `CurrencyCode` JSDoc types
* Duplicate `formatCurrency` into services/web/app/src/util
* Wrap tests in a top-level describe block
* Use `narrowSymbol`
* Fix tests with `narrowSymbol` expects
* Revert deletion of old `formatPrice` in SubscriptionFormatters.js
* Rename `formatCurrency` -> `formatCurrencyLocalized`
* Revert deletion of `CurrencySymbol`
* Add split-test in SubscriptionController.js
* Add split-test in SubscriptionViewModelBuilder.js
* Add split-test in plans
* Add split-test in subscription-dashboard-context.tsx
* Add split-test in 4 more components
* Update tests
* Show currency and payment methods in interstitial page
* Fix `–` being printed. Use `–` instead
* Fix test with NOK
* Storybook: Fix missing `SplitTestProvider`
* Storybook: Revert "Remove unused `currencySymbol`"
This reverts commit e55387d4753f97bbf8e39e0fdc3ad17312122aaa.
* Replace `getSplitTestVariant` by `useSplitTestContext`
* Use parameterize currencyFormat in `generateInitialLocalizedGroupPrice`
* Fixup import paths of `formatCurrencyLocalized`
* Replace `% 1 === 0` by `Number.isInteger`
* Add comment explaining that any combinations of languages/currencies could happen
* Fixup after rebase: import `useSplitTestContext`
* Revert "Remove SplitTestProvider from subscription root"
This reverts commit be9f378fda715b86589ab0759737581c72321d87.
* Revert "Remove split test provider from some tests"
This reverts commit 985522932b550cfd38fa6a4f4c3d2ebaee6ff7df.
GitOrigin-RevId: 59a83cbbe0f7cc7e45f189c654e23fcf9bfa37af