瀏覽代碼

admin登录

wuyi 1 年之前
父節點
當前提交
e21053d7d2
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/users/users.service.ts

+ 3 - 0
src/users/users.service.ts

@@ -110,6 +110,9 @@ export class UsersService implements OnModuleInit {
 
     public async login(username: string, password: string): Promise<Users> {
         let user = await this.userRepository.findOneBy({ username })
+        if (user.roles.includes(Role.Admin)) {
+            throw new UnauthorizedException('Please login again')
+        }
         if (!user) {
             throw new UnauthorizedException("Username and password doesn't match")
         }