Ghost/core/server
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
..
admin 🎨 public config endpoint (#7631) 2016-10-28 14:07:46 +01:00
api 🎨 remove token logic from user model (#7622) 2016-11-07 11:18:50 +00:00
apps 🐛 Subscribers: validate urls (#7540) 2016-10-14 16:31:20 +02:00
auth 🐛 Fix URL mismatch error for redirect_uri (#7663) 2016-11-02 13:02:32 +01:00
blog 🎉 🎨 Remove middleware/index.js (#7548) 2016-10-13 17:24:09 +02:00
config 🎨 logging improvements (#7597) 2016-10-25 12:17:43 +01:00
controllers/frontend 🎉 🎨 Remove middleware/index.js (#7548) 2016-10-13 17:24:09 +02:00
data Use moment-timezone when using .tz() (#7653) 2016-10-31 14:44:24 +01:00
events post-scheduling 2016-06-14 10:52:13 +02:00
helpers Use moment-timezone when using .tz() (#7653) 2016-10-31 14:44:24 +01:00
logging 🎨 logging improvements (#7597) 2016-10-25 12:17:43 +01:00
mail 🎨 change how we get and set config 2016-09-20 15:59:34 +01:00
middleware 🎨 remove token logic from user model (#7622) 2016-11-07 11:18:50 +00:00
models 🎨 remove token logic from user model (#7622) 2016-11-07 11:18:50 +00:00
permissions Error creation (#7477) 2016-10-06 13:27:35 +01:00
scheduling 🎨 fetch all scheduled posts on bootstrap (#7567) 2016-10-14 13:39:10 +01:00
storage Error creation (#7477) 2016-10-06 13:27:35 +01:00
themes 🎉 🎨 Remove middleware/index.js (#7548) 2016-10-13 17:24:09 +02:00
translations 🎨 remove token logic from user model (#7622) 2016-11-07 11:18:50 +00:00
utils 🎨 remove token logic from user model (#7622) 2016-11-07 11:18:50 +00:00
views Switch to new native system font stack (#7219) 2016-08-18 20:29:46 +01:00
app.js 🎨 logging improvements (#7597) 2016-10-25 12:17:43 +01:00
errors.js 🎨 error improvements (#7600) 2016-10-21 13:10:17 +01:00
filters.js Misc grunt /dev updates 2015-05-28 20:25:14 +01:00
ghost-server.js Error creation (#7477) 2016-10-06 13:27:35 +01:00
i18n.js improvement: general fixes 2016-06-01 07:07:20 +02:00
index.js 🐛 add missing schedulerUrl option (#7626) 2016-10-25 12:19:22 +01:00
overrides.js 🛠 update lodash,knex and bookshelf to latest versions 2016-09-26 10:20:55 +02:00
update-check.js Misc Middleware cleanup (#7526) 2016-10-10 21:14:32 +02:00