@@ -436,14 +436,6 @@ module.exports = function(crowi) {
});
};
- userSchema.statics.isPasswordSetById = async function(userId) {
- if (userId == null) {
- return Promise.resolve(null);
- }
- const user = await this.findOne({ _id: userId });
- return (user.password != null);
- };
-
userSchema.statics.findUserByUsername = function(username) {
if (username == null) {
return Promise.resolve(null);
@@ -147,8 +147,18 @@ module.exports = (crowi) => {
* type: boolean
*/
router.get('/is-password-set', accessTokenParser, loginRequiredStrictly, async(req, res) => {
- const isPasswordSet = await User.isPasswordSetById(req.user._id);
- return res.apiv3({ isPasswordSet });
+ const { _id } = req.user;
+
+ try {
+ const user = await User.findOne({ _id });
+ const isPasswordSet = user.isPasswordSet();
+ return res.apiv3({ isPasswordSet });
+ }
+ catch (err) {
+ logger.error(err);
+ return res.apiv3Err('update-personal-settings-failed');
/**