Skip to content

Commit 8f54475

Browse files
committed
fix lint
1 parent 4ba4916 commit 8f54475

File tree

1 file changed

+92
-92
lines changed

1 file changed

+92
-92
lines changed

src/Routers/UsersRouter.js

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -202,113 +202,113 @@ export class UsersRouter extends ClassesRouter {
202202
try {
203203
const user = await this._authenticateUserFromRequest(req);
204204
const authData = req.body && req.body.authData;
205-
// Check if user has provided their required auth providers
206-
Auth.checkIfUserHasProvidedConfiguredProvidersForLogin(
207-
req,
208-
authData,
209-
user.authData,
210-
req.config
211-
);
212-
213-
let authDataResponse;
214-
let validatedAuthData;
215-
if (authData) {
216-
const res = await Auth.handleAuthDataValidation(
205+
// Check if user has provided their required auth providers
206+
Auth.checkIfUserHasProvidedConfiguredProvidersForLogin(
207+
req,
217208
authData,
218-
new RestWrite(
219-
req.config,
220-
req.auth,
221-
'_User',
222-
{ objectId: user.objectId },
223-
req.body || {},
224-
user,
225-
req.info.clientSDK,
226-
req.info.context
227-
),
228-
user
209+
user.authData,
210+
req.config
229211
);
230-
authDataResponse = res.authDataResponse;
231-
validatedAuthData = res.authData;
232-
}
233212

234-
// handle password expiry policy
235-
if (req.config.passwordPolicy && req.config.passwordPolicy.maxPasswordAge) {
236-
let changedAt = user._password_changed_at;
213+
let authDataResponse;
214+
let validatedAuthData;
215+
if (authData) {
216+
const res = await Auth.handleAuthDataValidation(
217+
authData,
218+
new RestWrite(
219+
req.config,
220+
req.auth,
221+
'_User',
222+
{ objectId: user.objectId },
223+
req.body || {},
224+
user,
225+
req.info.clientSDK,
226+
req.info.context
227+
),
228+
user
229+
);
230+
authDataResponse = res.authDataResponse;
231+
validatedAuthData = res.authData;
232+
}
237233

238-
if (!changedAt) {
234+
// handle password expiry policy
235+
if (req.config.passwordPolicy && req.config.passwordPolicy.maxPasswordAge) {
236+
let changedAt = user._password_changed_at;
237+
238+
if (!changedAt) {
239239
// password was created before expiry policy was enabled.
240240
// simply update _User object so that it will start enforcing from now
241-
changedAt = new Date();
242-
req.config.database.update(
243-
'_User',
244-
{ username: user.username },
245-
{ _password_changed_at: Parse._encode(changedAt) }
246-
);
247-
} else {
241+
changedAt = new Date();
242+
req.config.database.update(
243+
'_User',
244+
{ username: user.username },
245+
{ _password_changed_at: Parse._encode(changedAt) }
246+
);
247+
} else {
248248
// check whether the password has expired
249-
if (changedAt.__type == 'Date') {
250-
changedAt = new Date(changedAt.iso);
249+
if (changedAt.__type == 'Date') {
250+
changedAt = new Date(changedAt.iso);
251+
}
252+
// Calculate the expiry time.
253+
const expiresAt = new Date(
254+
changedAt.getTime() + 86400000 * req.config.passwordPolicy.maxPasswordAge
255+
);
256+
if (expiresAt < new Date())
257+
// fail of current time is past password expiry time
258+
{ throw new Parse.Error(
259+
Parse.Error.OBJECT_NOT_FOUND,
260+
'Your password has expired. Please reset your password.'
261+
); }
251262
}
252-
// Calculate the expiry time.
253-
const expiresAt = new Date(
254-
changedAt.getTime() + 86400000 * req.config.passwordPolicy.maxPasswordAge
255-
);
256-
if (expiresAt < new Date())
257-
// fail of current time is past password expiry time
258-
{ throw new Parse.Error(
259-
Parse.Error.OBJECT_NOT_FOUND,
260-
'Your password has expired. Please reset your password.'
261-
); }
262263
}
263-
}
264264

265-
// Remove hidden properties.
266-
UsersRouter.removeHiddenProperties(user);
267-
268-
await req.config.filesController.expandFilesInObject(req.config, user);
269-
270-
// Before login trigger; throws if failure
271-
await maybeRunTrigger(
272-
TriggerTypes.beforeLogin,
273-
req.auth,
274-
Parse.User.fromJSON(Object.assign({ className: '_User' }, user)),
275-
null,
276-
req.config,
277-
req.info.context
278-
);
279-
280-
// If we have some new validated authData update directly
281-
if (validatedAuthData && Object.keys(validatedAuthData).length) {
282-
await req.config.database.update(
283-
'_User',
284-
{ objectId: user.objectId },
285-
{ authData: validatedAuthData },
286-
{}
265+
// Remove hidden properties.
266+
UsersRouter.removeHiddenProperties(user);
267+
268+
await req.config.filesController.expandFilesInObject(req.config, user);
269+
270+
// Before login trigger; throws if failure
271+
await maybeRunTrigger(
272+
TriggerTypes.beforeLogin,
273+
req.auth,
274+
Parse.User.fromJSON(Object.assign({ className: '_User' }, user)),
275+
null,
276+
req.config,
277+
req.info.context
287278
);
288-
}
289279

290-
const { sessionData, createSession } = RestWrite.createSession(req.config, {
291-
userId: user.objectId,
292-
createdWith: {
293-
action: 'login',
294-
authProvider: 'password',
295-
},
296-
installationId: req.info.installationId,
297-
});
280+
// If we have some new validated authData update directly
281+
if (validatedAuthData && Object.keys(validatedAuthData).length) {
282+
await req.config.database.update(
283+
'_User',
284+
{ objectId: user.objectId },
285+
{ authData: validatedAuthData },
286+
{}
287+
);
288+
}
289+
290+
const { sessionData, createSession } = RestWrite.createSession(req.config, {
291+
userId: user.objectId,
292+
createdWith: {
293+
action: 'login',
294+
authProvider: 'password',
295+
},
296+
installationId: req.info.installationId,
297+
});
298298

299-
user.sessionToken = sessionData.sessionToken;
299+
user.sessionToken = sessionData.sessionToken;
300300

301-
await createSession();
301+
await createSession();
302302

303-
const afterLoginUser = Parse.User.fromJSON(Object.assign({ className: '_User' }, user));
304-
await maybeRunTrigger(
305-
TriggerTypes.afterLogin,
306-
{ ...req.auth, user: afterLoginUser },
307-
afterLoginUser,
308-
null,
309-
req.config,
310-
req.info.context
311-
);
303+
const afterLoginUser = Parse.User.fromJSON(Object.assign({ className: '_User' }, user));
304+
await maybeRunTrigger(
305+
TriggerTypes.afterLogin,
306+
{ ...req.auth, user: afterLoginUser },
307+
afterLoginUser,
308+
null,
309+
req.config,
310+
req.info.context
311+
);
312312

313313
if (authDataResponse) {
314314
user.authDataResponse = authDataResponse;

0 commit comments

Comments
 (0)