MCPcopy Index your code
hub / github.com/parse-community/parse-server / resetPassword

Method resetPassword

src/Routers/PagesRouter.js:179–246  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

177 }
178
179 resetPassword(req) {
180 const config = req.config;
181
182 if (!config) {
183 this.invalidRequest();
184 }
185
186 const { new_password, token: rawToken } = req.body || {};
187 const token = typeof rawToken === 'string' ? rawToken : undefined;
188
189 if ((!token || !new_password) && req.xhr === false) {
190 return this.goToPage(req, pages.passwordResetLinkInvalid);
191 }
192
193 if (!token) {
194 throw new Parse.Error(Parse.Error.OTHER_CAUSE, 'Missing token');
195 }
196
197 if (!new_password) {
198 throw new Parse.Error(Parse.Error.PASSWORD_MISSING, 'Missing password');
199 }
200
201 return config.userController
202 .updatePassword(token, new_password)
203 .then(
204 () => {
205 return Promise.resolve({
206 success: true,
207 });
208 },
209 err => {
210 return Promise.resolve({
211 success: false,
212 err,
213 });
214 }
215 )
216 .then(result => {
217 if (req.xhr) {
218 if (result.success) {
219 return Promise.resolve({
220 status: 200,
221 response: 'Password successfully reset',
222 });
223 }
224 if (result.err) {
225 throw new Parse.Error(Parse.Error.OTHER_CAUSE, `${result.err}`);
226 }
227 }
228
229 const query = result.success
230 ? {}
231 : {
232 [pageParams.token]: token,
233 [pageParams.appId]: config.applicationId,
234 [pageParams.error]: result.err,
235 [pageParams.appName]: config.appName,
236 };

Callers 2

mountPagesRoutesMethod · 0.95
resetPasswordFunction · 0.80

Calls 3

invalidRequestMethod · 0.95
goToPageMethod · 0.95
updatePasswordMethod · 0.80

Tested by 1

resetPasswordFunction · 0.64