diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-04-10 15:04:27 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-04-10 15:04:27 +0900 |
| commit | 626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c (patch) | |
| tree | 23b89c000b1b169c36cffc7a345a2fc1ebe33347 /src/server/api/endpoints/i/update-email.ts | |
| parent | Delete get-user-summary.ts (diff) | |
| download | misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.tar.gz misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.tar.bz2 misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.zip | |
テーブル分割
Diffstat (limited to 'src/server/api/endpoints/i/update-email.ts')
| -rw-r--r-- | src/server/api/endpoints/i/update-email.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/server/api/endpoints/i/update-email.ts b/src/server/api/endpoints/i/update-email.ts index 253017535f..d98f0d753e 100644 --- a/src/server/api/endpoints/i/update-email.ts +++ b/src/server/api/endpoints/i/update-email.ts @@ -8,7 +8,7 @@ import config from '../../../../config'; import * as ms from 'ms'; import * as bcrypt from 'bcryptjs'; import { apiLogger } from '../../logger'; -import { Users } from '../../../../models'; +import { Users, UserProfiles } from '../../../../models'; export const meta = { requireCredential: true, @@ -32,14 +32,16 @@ export const meta = { }; export default define(meta, async (ps, user) => { + const profile = await UserProfiles.findOne({ userId: user.id }); + // Compare password - const same = await bcrypt.compare(ps.password, user.password); + const same = await bcrypt.compare(ps.password, profile.password); if (!same) { throw new Error('incorrect password'); } - await Users.update(user.id, { + await UserProfiles.update({ userId: user.id }, { email: ps.email, emailVerified: false, emailVerifyCode: null @@ -56,7 +58,7 @@ export default define(meta, async (ps, user) => { if (ps.email != null) { const code = rndstr('a-z0-9', 16); - await Users.update(user.id, { + await UserProfiles.update({ userId: user.id }, { emailVerifyCode: code }); |