MCPcopy Create free account
hub / github.com/CloudBoost/cloudboost / resetPassword

Function resetPassword

services/cloudUser.js:143–177  ·  view source on GitHub ↗
(appId, email, accessList, isMasterKey)

Source from the content-addressed store, hash-verified

141 Reject->Error on find User or No user or sendResetPassword()
142 */
143 resetPassword(appId, email, accessList, isMasterKey) {
144 const deferred = q.defer();
145
146 try {
147 customService.findOne(appId, Collections.User, {
148 email,
149 }, null, null, null, accessList, isMasterKey).then((user) => {
150 if (!user) {
151 return deferred.reject(`User with email ${email} not found.`);
152 }
153
154
155 // Send an email to reset user password here.
156 const passwordResetKey = crypto.createHmac('sha256', config.secureKey)
157 .update(user.password)
158 .digest('hex');
159
160 mailService.sendResetPasswordMail(appId, email, user, passwordResetKey).then((resp) => {
161 deferred.resolve(resp);
162 }, (error) => {
163 deferred.reject(error);
164 });
165 }, (error) => {
166 deferred.reject(error);
167 });
168 } catch (err) {
169 winston.log('error', {
170 error: String(err),
171 stack: new Error().stack,
172 });
173 deferred.reject(err);
174 }
175
176 return deferred.promise;
177 },
178
179 resetUserPassword(appId, username, newPassword, resetKey, accessList, isMasterKey, encryption_key) {
180 const deferred = q.defer();

Callers

nothing calls this directly

Calls 1

findOneMethod · 0.80

Tested by

no test coverage detected