Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Rename auth flag #100

Merged
merged 3 commits into from
Sep 12, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "make-magic",
"version": "4.2.0",
"version": "4.2.1",
"description": "A tool for quickly scaffolding an app with Magic authentication baked-in!",
"repository": "magiclabs/create-magic-app",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion scaffolds/nextjs-dedicated-wallet/scaffold.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default createScaffold<NextDedicatedWalletData>(
<Template source="./src/styles" />
<Template source="./src/utils" />

{data.selectedAuthTypes.map((authType) => (
{data.loginMethods.map((authType) => (
<React.Fragment key={authType}>
<Template source={`./src/components/magic/auth/${authType.replaceAll(' ', '')}.tsx`} />
{(authType === 'Discord' ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LoginProps } from '@/utils/types'
import Header from './Header'
<% selectedAuthTypes.forEach(authType => { %>
<% loginMethods.forEach(authType => { %>
<%-`import ${authType.replaceAll(' ', '')} from './auth/${authType.replaceAll(' ', '')}';`-%>
<% }) %>

Expand All @@ -9,7 +9,7 @@ const Login = ({ token, setToken }: LoginProps) => {
<div className="login-page">
<Header />
<div className="login-method-grid">
<% selectedAuthTypes.forEach(authType => { %>
<% loginMethods.forEach(authType => { %>
<% if (authType !== "Social Logins") { %>
<%-`<${authType.replaceAll(' ', '')} token={token} setToken={setToken} />`-%>
<% } %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { LoginProps } from '@/utils/types';
import Card from '@/components/ui/Card';
import CardHeader from '@/components/ui/CardHeader';
import { LoginMethod } from '@/utils/common';
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<%-`import UpdateEmail from '../wallet-methods/UpdateEmail'`-%>
<% }%>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<%-`import UpdatePhone from '../wallet-methods/UpdatePhone'`-%>
<% }%>

Expand All @@ -21,15 +21,15 @@ const WalletMethods = ({ token, setToken }: LoginProps) => {
return (
<Card>
<CardHeader id="methods">User Methods</CardHeader>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<%-`{loginMethod && loginMethod == 'EMAIL' && (
<>
<UpdateEmail />
<Divider />
</>
)}`-%>
<% }%>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<%-`{loginMethod && loginMethod == 'SMS' && (
<>
<UpdatePhone />
Expand Down
2 changes: 1 addition & 1 deletion scaffolds/nextjs-flow-dedicated-wallet/scaffold.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default createScaffold<NextDedicatedWalletData>(
<Template source="./src/styles" />
<Template source="./src/utils" />

{data.selectedAuthTypes.map((authType) => (
{data.loginMethods.map((authType) => (
<React.Fragment key={authType}>
<Template source={`./src/components/magic/auth/${authType.replaceAll(' ', '')}.tsx`} />
{(authType === 'Discord' ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {LoginProps} from '@/utils/types'
import Header from './Header'
<% selectedAuthTypes.forEach(authType => { %>
<% loginMethods.forEach(authType => { %>
<%-`import ${authType.replaceAll(' ', '')} from './auth/${authType.replaceAll(' ', '')}';`-%>
<% }) %>

Expand All @@ -9,7 +9,7 @@ const Login = ({token, setToken}: LoginProps) => {
<div className='login-page'>
<Header />
<div className='login-method-grid'>
<% selectedAuthTypes.forEach(authType => { %>
<% loginMethods.forEach(authType => { %>
<% if (authType !== "Social Logins") { %>
<%-`<${authType.replaceAll(' ', '')} token={token} setToken={setToken} />`-%>
<% } %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import CardHeader from '@/components/ui/CardHeader'
import {LoginMethod} from '@/utils/common'
import GetIdToken from '../wallet-methods/GetIdToken'
import GetMetadata from '../wallet-methods/GetMetadata'
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<%-`import UpdateEmail from '../wallet-methods/UpdateEmail'`-%>
<% }%>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<%-`import UpdatePhone from '../wallet-methods/UpdatePhone'`-%>
<% }%>

Expand All @@ -21,15 +21,15 @@ const WalletMethods = ({token, setToken}: LoginProps) => {
return (
<Card>
<CardHeader id='methods'>Wallet Methods</CardHeader>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<%-`{loginMethod && loginMethod == 'EMAIL' && (
<>
<UpdateEmail />
<Divider />
</>
)}`-%>
<% }%>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<%-`{loginMethod && loginMethod == 'SMS' && (
<>
<UpdatePhone />
Expand Down
2 changes: 1 addition & 1 deletion scaffolds/nextjs-solana-dedicated-wallet/scaffold.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default createScaffold<NextDedicatedWalletData>(
<Template source="./src/styles" />
<Template source="./src/utils" />

{data.selectedAuthTypes.map(
{data.loginMethods.map(
(authType) =>
authType !== 'Social Logins' && (
<React.Fragment key={authType}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {LoginProps} from '@/utils/types'
import Header from './Header'
<% selectedAuthTypes.forEach(authType => { %>
<% loginMethods.forEach(authType => { %>
<%-`import ${authType.replaceAll(' ', '')} from './auth/${authType.replaceAll(' ', '')}';`-%>
<% }) %>

Expand All @@ -9,7 +9,7 @@ const Login = ({token, setToken}: LoginProps) => {
<div className='login-page'>
<Header />
<div className='login-method-grid'>
<% selectedAuthTypes.forEach(authType => { %>
<% loginMethods.forEach(authType => { %>
<% if (authType !== "Social Logins") { %>
<%-`<${authType.replaceAll(' ', '')} token={token} setToken={setToken} />`-%>
<% } %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import CardHeader from '@/components/ui/CardHeader'
import {LoginMethod} from '@/utils/common'
import GetIdToken from '../wallet-methods/GetIdToken'
import GetMetadata from '../wallet-methods/GetMetadata'
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<%-`import UpdateEmail from '../wallet-methods/UpdateEmail'`-%>
<% }%>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<%-`import UpdatePhone from '../wallet-methods/UpdatePhone'`-%>
<% }%>

Expand All @@ -21,15 +21,15 @@ const WalletMethods = ({token, setToken}: LoginProps) => {
return (
<Card>
<CardHeader id='methods'>Wallet Methods</CardHeader>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%>
<%-`{loginMethod && loginMethod == 'EMAIL' && (
<>
<UpdateEmail />
<Divider />
</>
)}`-%>
<% }%>
<% if(selectedAuthTypes.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%>
<%-`{loginMethod && loginMethod == 'SMS' && (
<>
<UpdatePhone />
Expand Down
6 changes: 3 additions & 3 deletions scaffolds/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ export namespace AuthTypePrompt {
];

export type Data = {
selectedAuthTypes: string[];
loginMethods: string[];
};

export const questions: Questions<Data> = {
type: 'multiselect',
name: 'selectedAuthTypes',
name: 'loginMethods',
message:
'How do you want your users to log in to their wallet? See Magic docs for help (https://magic.link/docs/auth/overview)',
hint: '(<space> to select, <return> to submit)',
Expand All @@ -214,7 +214,7 @@ export namespace AuthTypePrompt {
};

export const flags: Flags<Partial<Data>> = {
selectedAuthTypes: {
loginMethods: {
type: [String],
description: `The auth method(s) of your choice. You can provide this flag multiple times to select multiple methods. (one of: ${authMethods.join(
', ',
Expand Down