summaryrefslogtreecommitdiff
path: root/src/api/endpoints
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/endpoints')
-rw-r--r--src/api/endpoints/drive/files/create.ts1
-rw-r--r--src/api/endpoints/i/change_password.ts6
-rw-r--r--src/api/endpoints/i/regenerate_token.ts2
3 files changed, 5 insertions, 4 deletions
diff --git a/src/api/endpoints/drive/files/create.ts b/src/api/endpoints/drive/files/create.ts
index 43dca7762a..7967c31187 100644
--- a/src/api/endpoints/drive/files/create.ts
+++ b/src/api/endpoints/drive/files/create.ts
@@ -20,6 +20,7 @@ module.exports = (file, params, user) => new Promise(async (res, rej) => {
return rej('file is required');
}
+ // TODO: 非同期にしたい。Promise対応してないんだろうか...
const buffer = fs.readFileSync(file.path);
fs.unlink(file.path, (err) => { if (err) console.log(err); });
diff --git a/src/api/endpoints/i/change_password.ts b/src/api/endpoints/i/change_password.ts
index faceded29d..16f1a2e4ec 100644
--- a/src/api/endpoints/i/change_password.ts
+++ b/src/api/endpoints/i/change_password.ts
@@ -22,15 +22,15 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
if (newPasswordErr) return rej('invalid new_password param');
// Compare password
- const same = bcrypt.compareSync(currentPassword, user.password);
+ const same = await bcrypt.compare(currentPassword, user.password);
if (!same) {
return rej('incorrect password');
}
// Generate hash of password
- const salt = bcrypt.genSaltSync(8);
- const hash = bcrypt.hashSync(newPassword, salt);
+ const salt = await bcrypt.genSalt(8);
+ const hash = await bcrypt.hash(newPassword, salt);
await User.update(user._id, {
$set: {
diff --git a/src/api/endpoints/i/regenerate_token.ts b/src/api/endpoints/i/regenerate_token.ts
index f96d10ebfc..653468330f 100644
--- a/src/api/endpoints/i/regenerate_token.ts
+++ b/src/api/endpoints/i/regenerate_token.ts
@@ -20,7 +20,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
if (passwordErr) return rej('invalid password param');
// Compare password
- const same = bcrypt.compareSync(password, user.password);
+ const same = await bcrypt.compare(password, user.password);
if (!same) {
return rej('incorrect password');