IaS1506
09/29/2022, 4:46 PMAlex
09/29/2022, 8:58 PMdreamer
09/30/2022, 12:45 AMrp
09/30/2022, 3:49 AMrp
09/30/2022, 3:49 AMexecreate
09/30/2022, 6:32 AMn1ru4l
09/30/2022, 10:10 AMsupertokens-core
v3.16.2
to v4.0.0
and I have a few questions around the database changes for the emailpassword_users
and thirdparty_users
table:
Why did you choose VARCHAR(256)
and VARCHAR(128)
over just TEXT
? The latter would have required no database migration and would not require a database migration in the future if the value changes again. Is it safe for me to use TEXT
instead of VARCHAR(256)
- or does supertokens-core
do some kind of database schema validation?
How did you manage to roll this out in production? In my current understanding it is not possible to apply this migration without locking the full database table and rewriting every single row. Wouldn't it been smarter (and also less "breaking") to follow this strategy:
1. Add a new columns "thirdparty_users"."third_party_user_id_new" and "emailpassword_users"."password_hash_new"
2. Run a script during outside of a migration/lock that copies the values from the old column to the new column
3. Write the super tokens code in a way that it can deal with both the old and new columns for the duration of the copy from old to new column period
Right now, for us running the migration will probably not take longer than a few seconds - however, I am concerned that in the future additional breaking database changes will make it harder for us to migrate to the latest versions.
Since you probably have much more users running on your hosted solution, I am especially curious on any insights on how you manged this (of course only if it is possible to share that information)!dreamer
09/30/2022, 5:15 PMAlex
09/30/2022, 5:41 PMemailpassword.init(
override=emailpassword.InputOverrideConfig(
apis=apis_override_email_password,
functions=functions_override_email_password,
)
What is the difference between apis and functions?
Within my override, how do I return a 400 response? For reference, this throws a 500 as expected:
def apis_override_email_password(param):
og_sign_in_post = param.sign_in_post
async def sign_in_post(
form_fields,
api_options,
user_context,
):
req = user_context.get("_default", {}).get("request")
if req:
raise Exception('Invalid password')
return await og_sign_in_post(form_fields, api_options, user_context)
param.sign_in_post = sign_in_post
return param
rp
09/30/2022, 5:42 PMrp
09/30/2022, 5:43 PMAlex
09/30/2022, 6:13 PMChunkygoo
10/01/2022, 12:10 AMChunkygoo
10/01/2022, 12:15 AMChunkygoo
10/01/2022, 12:19 AMChunkygoo
10/01/2022, 12:20 AMPPaii
10/01/2022, 4:40 AMtommykhumarga
10/01/2022, 12:40 PMERROR [ExceptionHandler] Nest can't resolve dependencies of the AuthGuard (?). Please make sure that the argument Object at index [0] is available in the AppModule context.
Below is my auth.guard.ts codes
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
import { Error as STError } from 'supertokens-node';
import { verifySession } from 'supertokens-node/recipe/session/framework/express';
import { VerifySessionOptions } from 'supertokens-node/recipe/session';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private readonly verifyOptions?: VerifySessionOptions) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
const ctx = context.switchToHttp();
let err = undefined;
const resp = ctx.getResponse();
// You can create an optional version of this by passing {sessionRequired: false} to verifySession
await verifySession(this.verifyOptions)(ctx.getRequest(), resp, (res) => {
err = res;
});
if (resp.headersSent) {
throw new STError({
message: 'RESPONSE_SENT',
type: 'RESPONSE_SENT'
});
}
if (err) {
throw err;
}
return true;
}
}
Did I missed something?
Thanksrp
10/01/2022, 2:09 PMaaronkopplin
10/01/2022, 5:40 PMrp
10/01/2022, 5:51 PMaaronkopplin
10/01/2022, 6:23 PMChunkygoo
10/01/2022, 6:38 PMrp
10/01/2022, 9:13 PMrp
10/01/2022, 9:14 PMChunkygoo
10/01/2022, 9:51 PMChunkygoo
10/01/2022, 10:12 PMAlex
10/01/2022, 10:18 PMrp
10/02/2022, 4:56 AMrp
10/02/2022, 4:59 AM