@steedos/service-identity-jwt 2.5.0-beta.9 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/package.service.js +13 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-identity-jwt",
|
|
3
|
-
"version": "2.5.0
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"steedos"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"description": "steedos package",
|
|
12
12
|
"repository": {},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@steedos/accounts": "2.5.0
|
|
14
|
+
"@steedos/accounts": "2.5.0",
|
|
15
15
|
"express": "4.18.1",
|
|
16
16
|
"jsonwebtoken": "8.5.1",
|
|
17
17
|
"passport": "^0.6.0",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "c4b366d1366ab52eb53da1a3ff4a80b16fd73cc0"
|
|
26
26
|
}
|
package/package.service.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: baozhoutao@steedos.com
|
|
3
3
|
* @Date: 2022-06-11 18:09:20
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2023-05-11 11:40:58
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
"use strict";
|
|
@@ -122,8 +122,17 @@ module.exports = {
|
|
|
122
122
|
|
|
123
123
|
const jwtAuthenticate = function (jwt_payload, done) {
|
|
124
124
|
try {
|
|
125
|
-
const { profile } = jwt_payload;
|
|
126
|
-
if(profile && profile
|
|
125
|
+
const { profile, idKey } = jwt_payload;
|
|
126
|
+
if(idKey && profile && profile[idKey]){
|
|
127
|
+
objectql.getObject('users').find({filters: [[idKey, '=', profile[idKey]]], fields: ['_id', 'name', 'email', 'username']}).then((records)=>{
|
|
128
|
+
if(records.length > 0){
|
|
129
|
+
const user = records[0];
|
|
130
|
+
return done(null, Object.assign({}, user, {id: user._id}))
|
|
131
|
+
}else{
|
|
132
|
+
return done('user not find', null)
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
}else if(profile && profile.email){
|
|
127
136
|
objectql.getObject('users').find({filters: [['email', '=', profile.email]], fields: ['_id', 'name', 'email', 'username']}).then((records)=>{
|
|
128
137
|
if(records.length > 0){
|
|
129
138
|
const user = records[0];
|