@canmingir/link-express 1.6.2 → 1.6.3
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
CHANGED
package/src/routes/oauth.js
CHANGED
|
@@ -105,19 +105,17 @@ router.post("/", async (req, res) => {
|
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
const prefixedUserId = `${provider}_${userId}`;
|
|
109
|
-
|
|
110
108
|
let accessToken;
|
|
111
109
|
|
|
112
110
|
if (projectId) {
|
|
113
111
|
const permissions = await Permission.findAll({
|
|
114
|
-
where: { userId
|
|
112
|
+
where: { userId, projectId, appId },
|
|
115
113
|
});
|
|
116
114
|
|
|
117
115
|
if (!permissions.length) {
|
|
118
116
|
accessToken = jwt.sign(
|
|
119
117
|
{
|
|
120
|
-
sub:
|
|
118
|
+
sub: userId,
|
|
121
119
|
iss: "nuc",
|
|
122
120
|
aid: appId,
|
|
123
121
|
provider: provider,
|
|
@@ -129,7 +127,7 @@ router.post("/", async (req, res) => {
|
|
|
129
127
|
} else {
|
|
130
128
|
accessToken = jwt.sign(
|
|
131
129
|
{
|
|
132
|
-
sub:
|
|
130
|
+
sub: userId,
|
|
133
131
|
iss: "nuc",
|
|
134
132
|
aud: projectId,
|
|
135
133
|
oid: permissions[0].organizationId,
|
|
@@ -145,7 +143,7 @@ router.post("/", async (req, res) => {
|
|
|
145
143
|
} else {
|
|
146
144
|
accessToken = jwt.sign(
|
|
147
145
|
{
|
|
148
|
-
sub:
|
|
146
|
+
sub: userId,
|
|
149
147
|
iss: "nuc",
|
|
150
148
|
aid: appId,
|
|
151
149
|
provider: provider,
|
|
@@ -47,7 +47,7 @@ describe("OAuth", () => {
|
|
|
47
47
|
|
|
48
48
|
equal(payload.iss, "nuc");
|
|
49
49
|
equal(payload.aud, "cb16e069-6214-47f1-9922-1f7fe7629525");
|
|
50
|
-
equal(payload.sub,
|
|
50
|
+
equal(payload.sub, `1001`);
|
|
51
51
|
deepEqual(payload.rls, ["OWNER"]);
|
|
52
52
|
equal(payload.aid, "977f5f57-8936-4388-8eb0-00a512cf01cc");
|
|
53
53
|
equal(payload.oid, "dfb990bb-81dd-4584-82ce-050eb8f6a12f");
|
|
@@ -76,7 +76,7 @@ describe("OAuth", () => {
|
|
|
76
76
|
|
|
77
77
|
const payload = jwt.decode(accessToken);
|
|
78
78
|
|
|
79
|
-
equal(payload.sub,
|
|
79
|
+
equal(payload.sub, `liam@rebellioncoffee.shop`);
|
|
80
80
|
equal(payload.iss, "nuc");
|
|
81
81
|
equal(payload.provider, provider);
|
|
82
82
|
equal(refreshToken, "lzk7FZGga5hHrfiAePtswijiJHIOev");
|
|
@@ -38,14 +38,6 @@ describe("Permissions", () => {
|
|
|
38
38
|
userId: "1001",
|
|
39
39
|
role: "OWNER",
|
|
40
40
|
},
|
|
41
|
-
{
|
|
42
|
-
id: "f81887da-d05f-4959-9def-6cd137857099",
|
|
43
|
-
appId: "977f5f57-8936-4388-8eb0-00a512cf01cc",
|
|
44
|
-
organizationId: "dfb990bb-81dd-4584-82ce-050eb8f6a12f",
|
|
45
|
-
projectId: "cb16e069-6214-47f1-9922-1f7fe7629525",
|
|
46
|
-
userId: "github_1001",
|
|
47
|
-
role: "OWNER",
|
|
48
|
-
},
|
|
49
41
|
{
|
|
50
42
|
id: "a1b60c53-66e2-4034-8654-38b83577f279",
|
|
51
43
|
appId: "977f5f57-8936-4388-8eb0-00a512cf01cc",
|
|
@@ -96,14 +88,6 @@ describe("Permissions", () => {
|
|
|
96
88
|
userId: "1001",
|
|
97
89
|
role: "OWNER",
|
|
98
90
|
},
|
|
99
|
-
{
|
|
100
|
-
id: "f81887da-d05f-4959-9def-6cd137857099",
|
|
101
|
-
appId: "977f5f57-8936-4388-8eb0-00a512cf01cc",
|
|
102
|
-
organizationId: "dfb990bb-81dd-4584-82ce-050eb8f6a12f",
|
|
103
|
-
projectId: "cb16e069-6214-47f1-9922-1f7fe7629525",
|
|
104
|
-
userId: "github_1001",
|
|
105
|
-
role: "OWNER",
|
|
106
|
-
},
|
|
107
91
|
{
|
|
108
92
|
id: "a1b60c53-66e2-4034-8654-38b83577f279",
|
|
109
93
|
appId: "977f5f57-8936-4388-8eb0-00a512cf01cc",
|
|
@@ -141,14 +125,6 @@ describe("Permissions", () => {
|
|
|
141
125
|
.expect(200);
|
|
142
126
|
|
|
143
127
|
deepEqual(permissions, [
|
|
144
|
-
{
|
|
145
|
-
id: "f81887da-d05f-4959-9def-6cd137857099",
|
|
146
|
-
appId: "977f5f57-8936-4388-8eb0-00a512cf01cc",
|
|
147
|
-
organizationId: "dfb990bb-81dd-4584-82ce-050eb8f6a12f",
|
|
148
|
-
projectId: "cb16e069-6214-47f1-9922-1f7fe7629525",
|
|
149
|
-
userId: "github_1001",
|
|
150
|
-
role: "OWNER",
|
|
151
|
-
},
|
|
152
128
|
{
|
|
153
129
|
id: "a1b60c53-66e2-4034-8654-38b83577f279",
|
|
154
130
|
appId: "977f5f57-8936-4388-8eb0-00a512cf01cc",
|
|
@@ -9,14 +9,6 @@
|
|
|
9
9
|
"userId": "1001",
|
|
10
10
|
"role": "OWNER"
|
|
11
11
|
},
|
|
12
|
-
{
|
|
13
|
-
"id": "f81887da-d05f-4959-9def-6cd137857099",
|
|
14
|
-
"appId": "977f5f57-8936-4388-8eb0-00a512cf01cc",
|
|
15
|
-
"organizationId": "dfb990bb-81dd-4584-82ce-050eb8f6a12f",
|
|
16
|
-
"projectId": "cb16e069-6214-47f1-9922-1f7fe7629525",
|
|
17
|
-
"userId": "github_1001",
|
|
18
|
-
"role": "OWNER"
|
|
19
|
-
},
|
|
20
12
|
{
|
|
21
13
|
"id": "b8e498d4-2d79-4e6e-b098-6a97e1d89a94",
|
|
22
14
|
"appId": "10b7bc8c-a49c-4002-b0ec-63599e4b5210",
|