Skip to content

Commit

Permalink
[react] Allow uppercase email address in ConnectWallet (#2219)
Browse files Browse the repository at this point in the history
  • Loading branch information
MananTank authored Jan 25, 2024
1 parent b34737d commit 3dfc003
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
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

0 comments on commit 3dfc003

Please sign in to comment.