@steedos/service-identity-jwt 2.5.0-beta.21 → 2.5.0-beta.23

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. 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-beta.21",
3
+ "version": "2.5.0-beta.23",
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-beta.21",
14
+ "@steedos/accounts": "2.5.0-beta.23",
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": "ed406927d05038a1b0655f7ff5c374e78233dd44"
25
+ "gitHead": "49ef7bdf5fca9be70922ebb2275ed0c20bca4ec6"
26
26
  }
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-06-11 18:09:20
4
- * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2022-11-29 16:09:26
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.email){
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];