From d954874fad36cb31a910a3bbce8bda04cb6e8be7 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期四, 10 八月 2023 11:30:42 +0800
Subject: [PATCH] 修改首次用户登录获取不到融云token的bug
---
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java | 38 ------------------
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java | 2
ard-work/src/main/java/com/ruoyi/storage/minio/utils/MinioService.java | 12 +++--
ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java | 10 +++--
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java | 17 ++++----
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java | 3 +
ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java | 10 +++--
7 files changed, 31 insertions(+), 61 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java b/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
index d10da3b..c4be437 100644
--- a/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
+++ b/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
@@ -71,10 +71,12 @@
@PreDestroy
public void destroyMediaMtx() {
- log.info("閿�姣乵ediaMtx");
- if (CmdUtils.isProcessRunning(processName)) {
- // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋�
- CmdUtils.stopProcess(processName);
+ if (mediamtxEnabled) {
+ log.info("閿�姣乵ediaMtx");
+ if (CmdUtils.isProcessRunning(processName)) {
+ // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋�
+ CmdUtils.stopProcess(processName);
+ }
}
}
diff --git a/ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java b/ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java
index 28c0053..e8b45ba 100644
--- a/ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java
+++ b/ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java
@@ -55,10 +55,12 @@
@PreDestroy
public void destroyMediaMtx() {
- log.info("閿�姣亀ebrtc-streamer");
- if (CmdUtils.isProcessRunning(processName)) {
- // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋�
- CmdUtils.stopProcess(processName);
+ if (webrtcEnabled) {
+ log.info("閿�姣亀ebrtc-streamer");
+ if (CmdUtils.isProcessRunning(processName)) {
+ // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋�
+ CmdUtils.stopProcess(processName);
+ }
}
}
}
diff --git a/ard-work/src/main/java/com/ruoyi/media/service/impl/MinioService.java b/ard-work/src/main/java/com/ruoyi/storage/minio/utils/MinioService.java
similarity index 87%
rename from ard-work/src/main/java/com/ruoyi/media/service/impl/MinioService.java
rename to ard-work/src/main/java/com/ruoyi/storage/minio/utils/MinioService.java
index 3c41b6c..2e095bc 100644
--- a/ard-work/src/main/java/com/ruoyi/media/service/impl/MinioService.java
+++ b/ard-work/src/main/java/com/ruoyi/storage/minio/utils/MinioService.java
@@ -1,4 +1,4 @@
-package com.ruoyi.media.service.impl;
+package com.ruoyi.storage.minio.utils;
import com.ruoyi.utils.tools.CmdUtils;
import com.sun.jna.Platform;
@@ -61,10 +61,12 @@
@PreDestroy
public void destroyMediaMtx() {
- log.info("閿�姣乵inio");
- if (CmdUtils.isProcessRunning(processName)) {
- // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋�
- CmdUtils.stopProcess(processName);
+ if (minioEnabled) {
+ log.info("閿�姣乵inio");
+ if (CmdUtils.isProcessRunning(processName)) {
+ // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋�
+ CmdUtils.stopProcess(processName);
+ }
}
}
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
index 780665c..736c164 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -54,7 +54,7 @@
AjaxResult ajax = AjaxResult.success();
// 鐢熸垚浠ょ墝
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
- loginBody.getUuid(),loginBody.getApp());
+ loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
return ajax;
}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
index c2a07d4..63da276 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
@@ -30,7 +30,10 @@
* 鐢ㄦ埛鍞竴鏍囪瘑
*/
private String token;
-
+ /**
+ * 铻嶄簯token
+ */
+ private String rongCloudToken;
/**
* 鐧诲綍鏃堕棿
*/
@@ -71,17 +74,13 @@
*/
private SysUser user;
- /**
- * 鏄惁app鐢ㄦ埛
- */
- private Boolean isApp;
- public Boolean getIsApp() {
- return isApp;
+ public String getRongCloudToken() {
+ return rongCloudToken;
}
- public void setIsApp(Boolean isApp) {
- this.isApp = isApp;
+ public void setRongCloudToken(String rongCloudToken) {
+ this.rongCloudToken = rongCloudToken;
}
public String getUserId()
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
index cd67a89..65f812c 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -95,43 +95,6 @@
getRongCloudToken(loginUser);
return token;
}
- public String login(String username, String password, String code, String uuid,Boolean isApp) {
- boolean captchaEnabled = configService.selectCaptchaEnabled();
- // 楠岃瘉鐮佸紑鍏�
- if (captchaEnabled) {
- validateCaptcha(username, code, uuid);
- }
- // 鐢ㄦ埛楠岃瘉
- Authentication authentication = null;
- try {
- UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
- AuthenticationContextHolder.setContext(authenticationToken);
- // 璇ユ柟娉曚細鍘昏皟鐢║serDetailsServiceImpl.loadUserByUsername
- authentication = authenticationManager.authenticate(authenticationToken);
- } catch (Exception e) {
- if (e instanceof BadCredentialsException) {
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
- throw new UserPasswordNotMatchException();
- } else {
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
- throw new ServiceException(e.getMessage());
- }
- } finally {
- AuthenticationContextHolder.clearContext();
- }
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
- LoginUser loginUser = (LoginUser) authentication.getPrincipal();
- recordLoginInfo(loginUser.getUserId());
- // 鐢熸垚token
- if(StringUtils.isNotNull(isApp))
- {
- loginUser.setIsApp(isApp);
- }
- String token = tokenService.createToken(loginUser);
- //鑾峰彇铻嶄簯token
- getRongCloudToken(loginUser);
- return token;
- }
/**
* 鏍¢獙楠岃瘉鐮�
*
@@ -176,6 +139,7 @@
String userId = loginUser.getUserId();
String nickName = loginUser.getUser().getNickName();
String token = rongCloudService.getToken(userId, nickName);
+ loginUser.setRongCloudToken(token);
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setRongCloudToken(token);
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java
index 6183d67..710b5d3 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java
@@ -142,7 +142,8 @@
public void refreshToken(LoginUser loginUser)
{
loginUser.setLoginTime(System.currentTimeMillis());
- if(StringUtils.isNull(loginUser.getIsApp()))
+ String appUserType = loginUser.getUser().getAppUserType();
+ if(StringUtils.isNull(appUserType))
{
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
// 鏍规嵁uuid灏唋oginUser缂撳瓨
--
Gitblit v1.9.3