@flink-app/oauth-plugin 2.0.0-alpha.73 → 2.0.0-alpha.74
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/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ const app = new FlinkApp<Context>({
|
|
|
107
107
|
});
|
|
108
108
|
} else {
|
|
109
109
|
// Link provider to existing user
|
|
110
|
-
await ctx.repos.userRepo.
|
|
110
|
+
await ctx.repos.userRepo.updateById(user._id, {
|
|
111
111
|
oauthProviders: [...user.oauthProviders, { provider, providerId: profile.id }],
|
|
112
112
|
});
|
|
113
113
|
}
|
|
@@ -664,7 +664,7 @@ onAuthSuccess: async ({ profile, provider }, ctx) => {
|
|
|
664
664
|
const isAlreadyLinked = existingProviders.some((p) => p.provider === provider && p.providerId === profile.id);
|
|
665
665
|
|
|
666
666
|
if (!isAlreadyLinked) {
|
|
667
|
-
await ctx.repos.userRepo.
|
|
667
|
+
await ctx.repos.userRepo.updateById(user._id, {
|
|
668
668
|
oauthProviders: [...existingProviders, { provider, providerId: profile.id }],
|
|
669
669
|
});
|
|
670
670
|
}
|
|
@@ -142,7 +142,7 @@ const CallbackOAuth = async ({ ctx, req }) => {
|
|
|
142
142
|
// Create or update OAuth connection
|
|
143
143
|
const existingConnection = await ctx.repos.oauthConnectionRepo.findByUserAndProvider(user._id, provider);
|
|
144
144
|
if (existingConnection) {
|
|
145
|
-
await ctx.repos.oauthConnectionRepo.
|
|
145
|
+
await ctx.repos.oauthConnectionRepo.updateById(existingConnection._id, {
|
|
146
146
|
accessToken: encryptedAccessToken,
|
|
147
147
|
refreshToken: encryptedRefreshToken,
|
|
148
148
|
scope: tokens.scope || "",
|
package/examples/basic-auth.ts
CHANGED
|
@@ -138,7 +138,7 @@ async function start() {
|
|
|
138
138
|
if (!isLinked) {
|
|
139
139
|
// Link new provider to existing user
|
|
140
140
|
console.log(`Linking ${provider} to existing user:`, user.email);
|
|
141
|
-
user = await ctx.repos.userRepo.
|
|
141
|
+
user = await ctx.repos.userRepo.updateById(user._id!, {
|
|
142
142
|
oauthProviders: [
|
|
143
143
|
...user.oauthProviders,
|
|
144
144
|
{ provider, providerId: profile.id },
|
|
@@ -134,7 +134,7 @@ async function start() {
|
|
|
134
134
|
`WARNING: Provider ID changed for ${provider}. Updating...`
|
|
135
135
|
);
|
|
136
136
|
// Update provider ID (rare case where user's provider ID changed)
|
|
137
|
-
user = await ctx.repos.userRepo.
|
|
137
|
+
user = await ctx.repos.userRepo.updateById(user._id!, {
|
|
138
138
|
oauthProviders: user.oauthProviders.map((p) =>
|
|
139
139
|
p.provider === provider
|
|
140
140
|
? { ...p, providerId: profile.id }
|
|
@@ -149,7 +149,7 @@ async function start() {
|
|
|
149
149
|
// Link new provider to existing user
|
|
150
150
|
console.log(`Linking ${provider} to existing user ${user.email}`);
|
|
151
151
|
|
|
152
|
-
user = await ctx.repos.userRepo.
|
|
152
|
+
user = await ctx.repos.userRepo.updateById(user._id!, {
|
|
153
153
|
oauthProviders: [
|
|
154
154
|
...user.oauthProviders,
|
|
155
155
|
{
|
|
@@ -350,7 +350,7 @@ const DeleteProviderHandler: Handler<
|
|
|
350
350
|
? updatedProviders[0].provider
|
|
351
351
|
: user.primaryProvider;
|
|
352
352
|
|
|
353
|
-
await ctx.repos.userRepo.
|
|
353
|
+
await ctx.repos.userRepo.updateById(userId, {
|
|
354
354
|
oauthProviders: updatedProviders,
|
|
355
355
|
primaryProvider: newPrimaryProvider,
|
|
356
356
|
updatedAt: new Date(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/oauth-plugin",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.74",
|
|
4
4
|
"description": "Flink plugin for OAuth 2.0 authentication with GitHub and Google providers",
|
|
5
5
|
"author": "joel@frost.se",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@flink-app/flink": ">=2.0.0-alpha.
|
|
13
|
+
"@flink-app/flink": ">=2.0.0-alpha.74",
|
|
14
14
|
"mongodb": "^6.15.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"jwt-simple": "^0.5.6",
|
|
21
21
|
"ts-node": "^10.9.2",
|
|
22
22
|
"tsc-watch": "^4.2.9",
|
|
23
|
-
"@flink-app/flink": "2.0.0-alpha.
|
|
24
|
-
"@flink-app/
|
|
25
|
-
"@flink-app/
|
|
23
|
+
"@flink-app/flink": "2.0.0-alpha.74",
|
|
24
|
+
"@flink-app/jwt-auth-plugin": "2.0.0-alpha.74",
|
|
25
|
+
"@flink-app/test-utils": "2.0.0-alpha.74"
|
|
26
26
|
},
|
|
27
27
|
"gitHead": "4243e3b3cd6d4e1ca001a61baa8436bf2bbe4113",
|
|
28
28
|
"scripts": {
|
|
@@ -177,7 +177,7 @@ const CallbackOAuth: GetHandler<any, any, PathParams, CallbackRequest> = async (
|
|
|
177
177
|
const existingConnection = await ctx.repos.oauthConnectionRepo.findByUserAndProvider(user._id, provider);
|
|
178
178
|
|
|
179
179
|
if (existingConnection) {
|
|
180
|
-
await ctx.repos.oauthConnectionRepo.
|
|
180
|
+
await ctx.repos.oauthConnectionRepo.updateById(existingConnection._id!, {
|
|
181
181
|
accessToken: encryptedAccessToken,
|
|
182
182
|
refreshToken: encryptedRefreshToken,
|
|
183
183
|
scope: tokens.scope || "",
|