mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-02 09:46:06 +02:00
Resolve #2623
This commit is contained in:
@@ -4,19 +4,26 @@ import * as speakeasy from 'speakeasy';
|
||||
import * as QRCode from 'qrcode';
|
||||
import User, { ILocalUser } from '../../../../../models/user';
|
||||
import config from '../../../../../config';
|
||||
import getParams from '../../../get-params';
|
||||
|
||||
export const meta = {
|
||||
requireCredential: true,
|
||||
secure: true
|
||||
|
||||
secure: true,
|
||||
|
||||
params: {
|
||||
password: {
|
||||
validator: $.str
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'password' parameter
|
||||
const [password, passwordErr] = $.str.get(params.password);
|
||||
if (passwordErr) return rej('invalid password param');
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(password, user.password);
|
||||
const same = await bcrypt.compare(ps.password, user.password);
|
||||
|
||||
if (!same) {
|
||||
return rej('incorrect password');
|
||||
|
||||
Reference in New Issue
Block a user