From 6fe253bd11364381b3a2cd2af4af84991f9cbdc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?old=E6=98=93?= <156663459@qq.com> Date: Tue, 8 Oct 2024 11:54:25 +0800 Subject: [PATCH] 1 --- .../Controllers/OAuthController.cs | 33 +++++++++++++------ New_College.Api/appsettings.json | 12 +++---- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/New_College.Api/Controllers/OAuthController.cs b/New_College.Api/Controllers/OAuthController.cs index c1fa122..9abf45d 100644 --- a/New_College.Api/Controllers/OAuthController.cs +++ b/New_College.Api/Controllers/OAuthController.cs @@ -43,19 +43,28 @@ namespace New_College.Controllers var response = new CasDoorToken(); string jwtStr = string.Empty; bool suc = false; - var userinfo = CasdoorHttpHelper.Http_Post>("/api/syswechat/user_info", null, - new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject( - new CasdoorRequest() - { - code = code, - client_id = CasdoorConfig.ClientId, - client_secret = CasdoorConfig.ClientSecret - }), - Encoding.UTF8, "application/json"));// + if (String.IsNullOrWhiteSpace(code)) + { + return new MessageModel() + { + success = false, + msg = "参数错误", + response = response + }; + } + var userinfo = CasdoorHttpHelper.Http_Post>("api/syswechat/user_info", null, + new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject( + new CasdoorRequest() + { + code = code, + client_id = CasdoorConfig.ClientId, + client_secret = CasdoorConfig.ClientSecret + }), + Encoding.UTF8, "application/json"));// if (userinfo != null && userinfo.code == 200 && userinfo.type == "success") { var user = (await _CustomerInfoServices.Query(q => q.UUID == userinfo.result.UnionId)).FirstOrDefault(); - if (user != null) + if (user == null) { //没有用户则注册一个新用户 user = new Model.Models.V_CustomerInfo() @@ -80,6 +89,10 @@ namespace New_College.Controllers { user.GZOpenId = userinfo.result.OpenId; user.ModifyTime = DateTime.UtcNow; + if (!string.IsNullOrEmpty(userinfo.result.Mobile)&&string.IsNullOrEmpty(user.Phone)) + { + user.Phone = userinfo.result.Mobile; + } await _CustomerInfoServices.Update(user); } var tokenModel = new SSOTokenModelJwt { UserId = user.Id.ToString(), NickName = user.NickName, LoginMode = LoginModeEnum.APP.ToString() }; diff --git a/New_College.Api/appsettings.json b/New_College.Api/appsettings.json index 80e0f1d..025ba0c 100644 --- a/New_College.Api/appsettings.json +++ b/New_College.Api/appsettings.json @@ -97,14 +97,14 @@ "DBType": 0, "Enabled": true, "HitRate": 20, - "Connection": "Server=192.168.104.108; Port=3306;SslMode=None;Database=volunteerapp; Uid=root; Pwd=Vs..127134;CharSet=utf8mb4;AllowLoadLocalInfile=true" + "Connection": "Server=192.168.104.103; Port=3306;SslMode=None;Database=volunteerapp; Uid=volunteerapp; Pwd=Vs..127134;CharSet=utf8mb4;AllowLoadLocalInfile=true;SslMode=none" }, { "ConnId": "MYSQL_CasDoor", "DBType": 0, "Enabled": true, "HitRate": 20, - "Connection": "Server=192.168.104.108; Port=3306;SslMode=None;Database=casdoor; Uid=root; Pwd=Vs..127134;CharSet=utf8mb4;AllowLoadLocalInfile=true" + "Connection": "Server=192.168.104.103; Port=3306;SslMode=None;Database=casdoor; Uid=casdoor; Pwd=Vs..127134;CharSet=utf8mb4;AllowLoadLocalInfile=true" }, { "ConnId": "WMBLOG_ORACLE", @@ -215,13 +215,13 @@ "endpoint": "https://oss-cn-shanghai.aliyuncs.com" }, "Casdoor": { - "Endpoint": "http://192.168.104.107:8000", + "Endpoint": "https://api.sso.ycymedu.com", "OrganizationName": "六纬生涯", "ApplicationName": "六纬生涯", "ApplicationType": "webapi", - "ClientId": "4c6d761417dbbdd665be", - "ClientSecret": "cc385a5d0efd5f7bf693d8c4574126158f7b0a8f", - "CallbackPath": "http://192.168.104.107:8000/login/oauth/authorize?client_id=ae6bdccc3a7821232b31&response_type=code&redirect_uri=http://192.168.103.100:8083/callback&scope=read&state=casdoor", + "ClientId": "18592781518917", + "ClientSecret": "9c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a", + "CallbackPath": "http://test.sso.ycymedu.com/login/oauth/authorize?client_id=776d639918192c449537&response_type=code&redirect_uri=http://192.168.100.106:8080/Home/FirstPage&scope=read&state=casdoor", "RequireHttpsMetadata": false }, "WeChatPay": {