You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All api-calls, that are doing some kind of account manipulation like: changePW, linkSteam, changeEmail etc.
should be only accessed through a AccountService/Repo.
This would have multiple benefits.
auto refresh token if expired (via JavaApiService)
no old "request" style code
error-handling can be done at a single place
clear parameters and return values
they are reusable (saw some duplicated code)
less testing hassle with mocking http, the service could also be injected in the router/controller
A solution could look something like:
Old:
request.post({url: process.env.API_URL+'/users/changePassword',headers: {Authorization: 'Bearer '+req.requestContainer.get('UserService').getUser()?.oAuthPassport.token},form: {currentPassword: oldPassword, newPassword }},function(err,res,body){if(err||res.statusCode!==200){error.parseApiErrors(body,flash)returnoverallRes.render('account/changePassword',{ flash })}// Successfully reset passwordflash.class='alert-success'flash.messages=[{msg: 'Your password was changed successfully. Please use the new password to log in!'}]flash.type='Success!'overallRes.render('account/changePassword',{ flash })})
All api-calls, that are doing some kind of account manipulation like: changePW, linkSteam, changeEmail etc.
should be only accessed through a AccountService/Repo.
This would have multiple benefits.
A solution could look something like:
Old:
new:
The text was updated successfully, but these errors were encountered: