Ver código fonte

feat: restore ak sk

ryanemax 7 meses atrás
pai
commit
b5c061bb63

+ 3 - 3
README.md

@@ -72,14 +72,14 @@ https://lljydpt8egql.u2-dev.hep.com.cn/
 
 ### AKSK
 AccessKey ID:
-669b25e1731d50c59f5494d1
+6682ab96b7bd5db59d6785a0
 AccessKey Secret:
 4cfc095a72a67e22065c97e90054315c
 
 ### 单页面应用
-AppID 669b25e1731d50c59f5494d1
+AppID 6682ab96b7bd5db59d6785a0
 
-AppSecret b800ac6533c640c3d1ea2b20ebe2e990
+AppSecret 4cfc095a72a67e22065c97e90054315c
 
 Token 端点
 https://textbook.u2-dev.hep.com.cn/oidc/token

+ 1 - 1
projects/textbook/src/modules/login/login/parse-authing.ts

@@ -35,7 +35,7 @@ export class ParseAuthing{
     initLoginModal(){
         this.authingGurad = new GuardFactory.Guard({
             host: 'https://textbook.u2-dev.hep.com.cn', // 应用的认证地址
-            appId: '669b25e1731d50c59f5494d1',
+            appId: '6682ab96b7bd5db59d6785a0',
             redirectUri:location.origin
         })
         // this.authingGurad.changeView("register:username-password")

+ 1 - 1
projects/textbook/src/modules/login/register/parse-authing.ts

@@ -35,7 +35,7 @@ export class ParseAuthing{
     initLoginModal(){
         this.authingGurad = new GuardFactory.Guard({
             host: 'https://textbook.u2-dev.hep.com.cn', // 应用的认证地址
-            appId: '669b25e1731d50c59f5494d1',
+            appId: '6682ab96b7bd5db59d6785a0',
             redirectUri:location.origin
         })
         // 使用 start 方法挂载 Guard 组件到你指定的 DOM 节点,登录成功后返回 userInfo

+ 1 - 1
server/cloud/authing/func-authing-org-sync.js

@@ -1,6 +1,6 @@
 const { ManagementClient } = require('authing-node-sdk')
 const managementClient  = new ManagementClient({
-    accessKeyId: '669b25e1731d50c59f5494d1',
+    accessKeyId: '6682ab96b7bd5db59d6785a0',
     accessKeySecret: "4cfc095a72a67e22065c97e90054315c",
     host: 'https://textbook.u2-dev.hep.com.cn', // 应用的认证地址
 })

+ 15 - 10
server/cloud/authing/func-authing-session-sync.js

@@ -31,7 +31,7 @@ async function syncSessionWithIdToken(token){
     // 通过用户的 id_token 初始化之后获取用户信息
 
     let authenticationClient = new AuthenticationClient({
-        appId: '669b25e1731d50c59f5494d1',
+        appId: '6682ab96b7bd5db59d6785a0',
         appHost: 'https://textbook.u2-dev.hep.com.cn', // 应用的认证地址
         token: token
     })
@@ -43,8 +43,10 @@ async function syncSessionWithIdToken(token){
     let sessionObjectId = generateObjectId(user?.id+user?.token);
     let username = user?.username || user?.phone || user?.email
     let ParseExistUser = await getParseUserByAuthingUser(user);
-    // console.log("ParseExistUser",ParseExistUser);
     let userId = ParseExistUser?.objectId || user?.id;
+    console.log("userId",userId);
+    console.log("authingUser",user);
+    console.log("ParseExistUser",ParseExistUser);
     let syncSessionSQL = `
     INSERT INTO "_User" (
         "objectId", "username","mobile","phone", "createdAt", "updatedAt",
@@ -88,7 +90,7 @@ async function syncSessionWithIdToken(token){
         try {
             // 查询:数据库版本信息
             let data = await pgClient().any(syncSessionSQL,params);
-            // console.log(data)
+            console.log("session sql",data)
             return {
                 sid:sessionObjectId,
                 uid:user?.id,
@@ -111,6 +113,7 @@ async function getParseUserByAuthingUser(user){
     "username"=$3 OR 
     "username"=$4 OR 
     "username"=$5 OR 
+    "username"=$6 OR 
     ("mobile" IS NOT NULL AND "mobile" = $4) OR 
     ("phone" IS NOT NULL AND "phone"  = $4) OR 
     ("mobile" IS NOT NULL AND "mobile" = $5) OR 
@@ -118,17 +121,17 @@ async function getParseUserByAuthingUser(user){
     ("email" IS NOT NULL AND "email" = $6)
     `
     let params = [
-        user?.id,
-        user?.externalId,
-        user?.username,
-        user?.phone,
-        user?.mobile,
-        user?.email
+        user?.id, //1
+        user?.externalId,//2
+        user?.username,//3
+        user?.phone,//4
+        user?.mobile,//5
+        user?.email//6
     ]
     let data = [] 
     try{
         data = await pgClient().any(sql,params);
-        // console.log("data",data)
+        console.log("data same user:",data)
         if(data?.length){
             return data[0]
         }
@@ -141,6 +144,8 @@ async function getParseUserByAuthingUser(user){
 
 const crypto = require('crypto');
 function generateObjectId(inputString) {
+    inputString = inputString || ""
+    inputString = String(inputString)
     const hash = crypto.createHash('sha256').update(inputString).digest('hex');
     const objectId = hash;
     return objectId;

+ 1 - 1
server/cloud/authing/test/test-verify-sms.js

@@ -2,7 +2,7 @@ const { AuthenticationClient, Models } = require('authing-node-sdk');
 
 const authenticationClient = new AuthenticationClient({
   // 需要替换成你的 Authing AppId、 Secret 和 Host
-  appId: '669b25e1731d50c59f5494d1',
+  appId: '6682ab96b7bd5db59d6785a0',
   appSecret: "4cfc095a72a67e22065c97e90054315c",
   appHost: 'https://textbook.u2-dev.hep.com.cn', // 应用的认证地址
 });

+ 1 - 1
server/cloud/authing/trigger-department.js

@@ -1,7 +1,7 @@
 // https://docs.authing.cn/v3/reference/sdk/node/management/%E7%AE%A1%E7%90%86%E7%BB%84%E7%BB%87%E6%9C%BA%E6%9E%84/update-department.html
 const { ManagementClient,Models } = require('authing-node-sdk')
 const managementClient  = new ManagementClient({
-    accessKeyId: '669b25e1731d50c59f5494d1', // 用户池级别AKSK
+    accessKeyId: '6682ab96b7bd5db59d6785a0', // 用户池级别AKSK
     accessKeySecret: "4cfc095a72a67e22065c97e90054315c",
     host: 'https://textbook.u2-dev.hep.com.cn', // 应用的认证地址
 })

+ 1 - 1
server/cloud/authing/trigger-user-save.js

@@ -1,7 +1,7 @@
 // https://docs.authing.co/v2/reference/sdk-for-node/management/UsersManagementClient.html
 const { ManagementClient } = require('authing-node-sdk')
 const managementClient  = new ManagementClient({
-    accessKeyId: '669b25e1731d50c59f5494d1',
+    accessKeyId: '6682ab96b7bd5db59d6785a0',
     accessKeySecret: "4cfc095a72a67e22065c97e90054315c",
     host: 'https://textbook.u2-dev.hep.com.cn', // 应用的认证地址
 })