Skip to content

[react] Allow uppercase email address in ConnectWallet #2219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/honest-flowers-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/react": patch
---

Allow uppercase letters in email in embeddedWallet, magicLink, paperWallet in ConnectWallet UI
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const EmbeddedWalletFormUI = (props: {
name="email"
type="email"
errorMessage={(_input) => {
const input = _input.replace(/\+/g, "");
const input = _input.replace(/\+/g, "").toLowerCase();
const emailRegex =
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,})$/g;
const isValidEmail = emailRegex.test(input);
Expand Down
7 changes: 4 additions & 3 deletions packages/react/src/wallet/wallets/magic/magicLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ const MagicUI: React.FC<{
name="magic-input"
type={type}
emptyErrorMessage={emptyErrorMessage}
errorMessage={(input) => {
errorMessage={(_input) => {
const input = _input.toLowerCase();
const isEmail = input.includes("@");
const isPhone = Number.isInteger(Number(input[input.length - 1]));

Expand Down Expand Up @@ -474,8 +475,8 @@ function useConnectMagic() {
data.type === "connect"
? {}
: isEmail
? { email: selectionData, chainId: activeChain.chainId }
: { phoneNumber: selectionData, chainId: activeChain.chainId },
? { email: selectionData, chainId: activeChain.chainId }
: { phoneNumber: selectionData, chainId: activeChain.chainId },
);
connected();
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/wallet/wallets/paper/PaperFormUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const PaperFormUI = (props: {
name="email"
type="email"
errorMessage={(_input) => {
const input = _input.replace(/\+/g, "");
const input = _input.replace(/\+/g, "").toLowerCase();
const emailRegex = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,})$/g;
const isValidEmail = emailRegex.test(input);
if (!isValidEmail) {
Expand Down