Ghost/core/server/utils
Katharina Irrgang 4e7779b783 🎨 remove token logic from user model (#7622)
* 🔥  remove User model functions

- validateToken
- generateToken
- resetPassword
- all this logic will re-appear in a different way

Token logic:
- was already extracted as separate PR, see https://github.com/TryGhost/Ghost/pull/7554
- we will use this logic in the controller, you will see in the next commits

Reset Password:
Was just a wrapper for calling the token logic and change the password.
We can reconsider keeping the function to call: changePassword and activate the status of the user - but i think it's fine to trigger these two actions from the controlling unit.

* 🔥  remove password reset tests from User model

- we already have unit tests for change password and the token logic
- i will re-check at the end if any test case is missing - but for now i will just burn the tests

*   add token logic to controlling unit

generateResetToken endpoint
- the only change here is instead of calling the User model to generate a token, we generate the token via utils
- we fetch the user by email, and generate a hash and return

resetPassword endpoint
- here we have changed a little bit more
- first of all: we have added the validation check if the new passwords match
- a new helper method to extract the token informations
- the brute force security check, which can be handled later from the new bruteforce middleware (see TODO)
- the actual reset function is doing the steps: load me the user, compare the token, change the password and activate the user
- we can think of wrapping these steps into a User model function
- i was not sure about it, because it is actually part of the controlling unit

[ci skip]

* 🎨  tidy up

- jscs
- jshint
- naming functions
- fixes

*   add a test for resetting the password

- there was none
- added a test to reset the password

* 🎨  add more token tests

- ensure quality
- ensure logic we had

* 🔥  remove compare new password check from User Model

- this part of controlling unit

*   compare new passwords for user endpoint

- we deleted the logic in User Model
- we are adding the logic to controlling unit

* 🐛  spam prevention forgotten can crash

- no validation happend before this middleware
- it just assumes that the root key is present
- when we work on our API, we need to ensure that
  1. pre validation happens
  2. we call middlewares
  3. ...

* 🎨  token translation key
2016-11-07 11:18:50 +00:00
..
asset-hash.js 🐛 Refresh assetHash on theme override (#7430) 2016-09-23 13:05:44 +02:00
cached-image-size-from-url.js [FEATURE] AMP (#7229) 2016-08-22 18:49:27 +02:00
downzero.js Add jscs task to grunt file and clean up files to adhere to jscs rules. 2014-09-17 21:44:29 -04:00
ghost-version.js Misc Middleware cleanup (#7526) 2016-10-10 21:14:32 +02:00
gravatar.js 🎨 change gravatar file design (#7553) 2016-10-13 13:52:22 +01:00
image-size-from-url.js 🎨 source out url utils from ConfigManager (#7347) 2016-09-20 15:59:34 +01:00
index.js 🎨 gravatar lookup in saving hook (#7561) 2016-10-14 15:37:40 +01:00
labs.js 🎨 change how we get and set config 2016-09-20 15:59:34 +01:00
make-absolute-urls.js 🎨 source out url utils from ConfigManager (#7347) 2016-09-20 15:59:34 +01:00
parse-package-json.js Harvest server side strings 2015-12-19 12:12:16 +01:00
pipeline.js Pipeline util tests, clean & fix 2015-11-03 09:14:44 +00:00
read-csv.js Add CSV parser for csv read utility 2016-06-07 10:47:56 +01:00
read-directory.js Add .git folder to ignore folders list 2015-12-01 21:14:23 +02:00
read-themes.js Add readThemes() utility to get a list of themes 2015-10-13 15:54:41 +02:00
remove-open-redirect-from-url.js Remove open redirect by removing double slashes from redirects (#7247) 2016-08-23 13:47:59 +02:00
sequence.js post-scheduling 2016-06-14 10:52:13 +02:00
social-urls.js Add helpers for facebook & twitter urls 2016-05-17 16:39:58 +01:00
tokens.js 🎨 remove token logic from user model (#7622) 2016-11-07 11:18:50 +00:00
url.js 🎨 change how we get and set config 2016-09-20 15:59:34 +01:00
visibility-filter.js Move internal tags out of labs (#7519) 2016-10-10 09:51:03 +01:00
zip-folder.js Use node-archiver to create zips (#7268) 2016-08-25 09:22:22 +02:00