From 613399cc6d14cfe5b8a245d462629ecee5deb2db Mon Sep 17 00:00:00 2001
From: xiaoQQya <xiaoQQya@126.com>
Date: 星期二, 17 十月 2023 17:49:31 +0800
Subject: [PATCH] fix(play): 修复单端口推流下级自定义 ssrc 时, 流注册后接口仍然超时的问题
---
src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
old mode 100644
new mode 100755
index 127e83b..b6f9183
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.vmanager.user;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
+import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.service.IRoleService;
@@ -21,10 +22,11 @@
import org.springframework.web.bind.annotation.*;
import javax.security.sasl.AuthenticationException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Tag(name = "鐢ㄦ埛绠$悊")
-
@RestController
@RequestMapping("/api/user")
public class UserController {
@@ -40,11 +42,13 @@
@GetMapping("/login")
@PostMapping("/login")
- @Operation(summary = "鐧诲綍")
+ @Operation(summary = "鐧诲綍", description = "鐧诲綍鎴愬姛鍚庤繑鍥濧ccessToken锛� 鍙互浠庤繑鍥炲�艰幏鍙栧埌涔熷彲浠ヤ粠鍝嶅簲澶翠腑鑾峰彇鍒帮紝" +
+ "鍚庣画鐨勮姹傞渶瑕佹坊鍔犺姹傚ご 'access-token'鎴栬�呮斁鍦ㄥ弬鏁伴噷")
+
@Parameter(name = "username", description = "鐢ㄦ埛鍚�", required = true)
@Parameter(name = "password", description = "瀵嗙爜锛�32浣峬d5鍔犲瘑锛�", required = true)
- public LoginUser login(@RequestParam String username, @RequestParam String password){
- LoginUser user = null;
+ public LoginUser login(HttpServletRequest request, HttpServletResponse response, @RequestParam String username, @RequestParam String password){
+ LoginUser user;
try {
user = SecurityUtils.login(username, password, authenticationManager);
} catch (AuthenticationException e) {
@@ -52,9 +56,14 @@
}
if (user == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒");
+ }else {
+ String jwt = JwtUtils.createToken(username);
+ response.setHeader(JwtUtils.getHeader(), jwt);
+ user.setAccessToken(jwt);
}
return user;
}
+
@PostMapping("/changePassword")
@Operation(summary = "淇敼瀵嗙爜")
@@ -74,8 +83,8 @@
if (user == null) {
throw new ControllerException(ErrorCode.ERROR100);
}
- int userId = SecurityUtils.getUserId();
- boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes()));
+ //int userId = SecurityUtils.getUserId();
+ boolean result = userService.changePassword(user.getId(), DigestUtils.md5DigestAsHex(password.getBytes()));
if (!result) {
throw new ControllerException(ErrorCode.ERROR100);
}
--
Gitblit v1.8.0