fix: hide user password
This commit is contained in:
parent
4ed74bfedf
commit
6bfd8ebf57
@ -3,8 +3,14 @@ import { PASSWORD } from '@nocobase/database';
|
|||||||
import cryptoRandomString from 'crypto-random-string';
|
import cryptoRandomString from 'crypto-random-string';
|
||||||
|
|
||||||
export async function check(ctx: actions.Context, next: actions.Next) {
|
export async function check(ctx: actions.Context, next: actions.Next) {
|
||||||
ctx.body = ctx.state.currentUser;
|
if (ctx.state.currentUser) {
|
||||||
await next();
|
const user = ctx.state.currentUser.toJSON();
|
||||||
|
delete user.password;
|
||||||
|
ctx.body = user;
|
||||||
|
await next();
|
||||||
|
} else {
|
||||||
|
ctx.throw(401, 'Unauthorized');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function login(ctx: actions.Context, next: actions.Next) {
|
export async function login(ctx: actions.Context, next: actions.Next) {
|
||||||
|
Loading…
Reference in New Issue
Block a user