Skip to content

Commit 80c6f28

Browse files
author
pedro
committed
fix:修复用户验证
1 parent a2c09ec commit 80c6f28

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

lib/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export class User extends Model {
224224

225225
static async verify(nickname: string, password: string): Promise<User> {
226226
// tslint:disable-next-line: await-promise
227-
const user = await this.findOne({ where: { nickname } });
227+
const user = await this.findOne({ where: { nickname, delete_time: null } });
228228
if (!user) {
229229
throw new NotFound({ msg: "用户不存在" });
230230
}

lib/extend.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@ function transform(obj: any, data: any) {
5353
* @param app app实例
5454
*/
5555
export const success = (app: Application) => {
56-
app.context.json = function(ex?: Exception) {
57-
throw new Success(ex);
56+
app.context.success = function(ex?: Exception) {
57+
this.type = "application/json";
58+
const suc = new Success(ex);
59+
let data = {
60+
error_code: suc.errorCode,
61+
msg: suc.msg,
62+
url: this.req.url
63+
};
64+
this.status = suc.code;
65+
this.body = JSON.stringify(data);
5866
};
5967
};
6068

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lin-mizar",
3-
"version": "0.0.1-alpha.19",
3+
"version": "0.0.1-alpha.22",
44
"description": "The core library of Lin CMS",
55
"main": "lin/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)