diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-07-18 05:26:58 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-07-18 05:26:58 +0900 |
| commit | d8c835fa517a81a11d3946b83076bfdc557d0849 (patch) | |
| tree | 4bd85ec65a19d04334e127c54c2baf6d5a58028c /src | |
| parent | Fix signin history (#5180) (diff) | |
| download | sharkey-d8c835fa517a81a11d3946b83076bfdc557d0849.tar.gz sharkey-d8c835fa517a81a11d3946b83076bfdc557d0849.tar.bz2 sharkey-d8c835fa517a81a11d3946b83076bfdc557d0849.zip | |
Fix signin (#5181)
* Revert "Fix signin history (#5180)"
This reverts commit a97c14a7b7b306e2ffee56642be93d90814ee299.
* fix signin
* failはfail専用に
* fix password less 200
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/api/private/signin.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/server/api/private/signin.ts b/src/server/api/private/signin.ts index 1e0694368f..fa573b69fa 100644 --- a/src/server/api/private/signin.ts +++ b/src/server/api/private/signin.ts @@ -53,9 +53,9 @@ export default async (ctx: Koa.BaseContext) => { // Compare password const same = await bcrypt.compare(password, profile.password!); - async function fail(status?: number, failure?: {error: string}) { + async function fail(status?: number, failure?: { error: string }) { // Append signin history - const record = await Signins.save({ + await Signins.save({ id: genId(), createdAt: new Date(), userId: user.id, @@ -64,23 +64,19 @@ export default async (ctx: Koa.BaseContext) => { success: false }); - // Publish signin event - publishMainStream(user.id, 'signin', await Signins.pack(record)); - - if (status && failure) { - ctx.throw(status, failure); - } + ctx.throw(status || 500, failure || { error: 'someting happened' }); } if (!profile.twoFactorEnabled) { if (same) { signin(ctx, user); + return; } else { await fail(403, { error: 'incorrect password' }); + return; } - return; } if (token) { @@ -169,6 +165,7 @@ export default async (ctx: Koa.BaseContext) => { if (isValid) { signin(ctx, user); + return; } else { await fail(403, { error: 'invalid challenge data' @@ -191,6 +188,7 @@ export default async (ctx: Koa.BaseContext) => { await fail(403, { error: 'no keys found' }); + return; } // 32 byte challenge @@ -219,6 +217,5 @@ export default async (ctx: Koa.BaseContext) => { ctx.status = 200; return; } - - await fail(); + // never get here }; |