Skip to content

Commit fc43e00

Browse files
committed
remove code not needed
1 parent 213a54e commit fc43e00

1 file changed

Lines changed: 15 additions & 32 deletions

File tree

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,28 @@
1-
import { AppwriteException, type Models } from '@appwrite.io/console';
1+
import { AppwriteException } from '@appwrite.io/console';
22

3-
const EMAIL_VERIFICATION_REQUIRED_ERROR_TYPE = 'user_email_not_verified';
4-
const CONSOLE_ACCOUNT_VERIFICATION_REQUIRED_TYPE = 'console_account_verification_required';
5-
6-
export function isEmailVerificationEnabled(
7-
consoleVariables: Models.ConsoleVariables | undefined
8-
): boolean {
9-
if (!consoleVariables) {
10-
return false;
11-
}
12-
13-
return String(consoleVariables._APP_CONSOLE_EMAIL_VERIFICATION) === 'true';
14-
}
15-
16-
export function isEmailVerificationRequiredError(type: string | undefined): boolean {
17-
return type === EMAIL_VERIFICATION_REQUIRED_ERROR_TYPE;
18-
}
19-
20-
function matchesVerifyEmailGate(type: string | undefined, message: string | undefined): boolean {
21-
if (isEmailVerificationRequiredError(type)) return true;
22-
if (type === CONSOLE_ACCOUNT_VERIFICATION_REQUIRED_TYPE) return true;
23-
if (message?.includes('Console account verification is required')) return true;
24-
return false;
25-
}
26-
27-
/**
28-
* Console APIs may return `user_email_not_verified`, `console_account_verification_required`,
29-
* or a message-only error when email verification is enforced for the console account.
30-
*/
3+
/** True when access is blocked until the console account email is verified. */
314
export function isVerifyEmailRedirectError(error: unknown): boolean {
325
if (error instanceof AppwriteException) {
33-
return matchesVerifyEmailGate(error.type, error.message);
6+
return (
7+
error.type === 'user_email_not_verified' ||
8+
error.type === 'console_account_verification_required' ||
9+
(error.message?.includes('Console account verification is required') ?? false)
10+
);
3411
}
35-
if (typeof error === 'object' && error !== null && 'message' in error) {
12+
13+
if (error && typeof error === 'object' && 'message' in error) {
3614
const msg = (error as { message: unknown }).message;
3715
if (typeof msg !== 'string') return false;
3816
const typ =
3917
'type' in error && typeof (error as { type: unknown }).type === 'string'
4018
? (error as { type: string }).type
4119
: undefined;
42-
return matchesVerifyEmailGate(typ, msg);
20+
return (
21+
typ === 'user_email_not_verified' ||
22+
typ === 'console_account_verification_required' ||
23+
msg.includes('Console account verification is required')
24+
);
4325
}
26+
4427
return false;
4528
}

0 commit comments

Comments
 (0)