Francisco "Klogan" Barros
Francisco "Klogan" Barros
KKinde
Created by Francisco "Klogan" Barros on 8/19/2024 in #💻┃support
[help] custom sign-up and sign-in pages
import { zodResolver } from '@hookform/resolvers/zod'
import { Button, Form } from '@zenif/react-web-components-v2'
import { passwordlessAuthSchema } from '@zenif/ts-zod'
import { useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'

type SignInFormProps = {
id: string
onSubmit: (data: { email: string }) => void
}

export function SignInForm({ id, onSubmit }: SignInFormProps) {
const { t } = useTranslation(['common', 'errors'])
const emailLabel = 'Email' // t('email', { ns: 'common' })

const methods = useForm({
defaultValues: { email: '' },
mode: 'onChange',
resolver: zodResolver(passwordlessAuthSchema),
})

const handleSubmit = methods.handleSubmit((data) => {
onSubmit(data)
})

return (
<Form.Root methods={methods} id={id} onSubmit={handleSubmit}>
<Form.FieldControl
control={methods.control}
name="email"
render={({ field }) => (
<Form.FieldRoot>
<Form.FieldLabel>{emailLabel}</Form.FieldLabel>
<Form.FieldInput placeholder={emailLabel} type="email" {...field} />
<Form.FieldHelperText />
<Form.FieldErrorText />
</Form.FieldRoot>
)}
/>
<Form.RootErrorText />
<Button type="submit">
Sign in
</Button>
</Form.Root>
)
}
import { zodResolver } from '@hookform/resolvers/zod'
import { Button, Form } from '@zenif/react-web-components-v2'
import { passwordlessAuthSchema } from '@zenif/ts-zod'
import { useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'

type SignInFormProps = {
id: string
onSubmit: (data: { email: string }) => void
}

export function SignInForm({ id, onSubmit }: SignInFormProps) {
const { t } = useTranslation(['common', 'errors'])
const emailLabel = 'Email' // t('email', { ns: 'common' })

const methods = useForm({
defaultValues: { email: '' },
mode: 'onChange',
resolver: zodResolver(passwordlessAuthSchema),
})

const handleSubmit = methods.handleSubmit((data) => {
onSubmit(data)
})

return (
<Form.Root methods={methods} id={id} onSubmit={handleSubmit}>
<Form.FieldControl
control={methods.control}
name="email"
render={({ field }) => (
<Form.FieldRoot>
<Form.FieldLabel>{emailLabel}</Form.FieldLabel>
<Form.FieldInput placeholder={emailLabel} type="email" {...field} />
<Form.FieldHelperText />
<Form.FieldErrorText />
</Form.FieldRoot>
)}
/>
<Form.RootErrorText />
<Button type="submit">
Sign in
</Button>
</Form.Root>
)
}
5 replies
KKinde
Created by Francisco "Klogan" Barros on 8/19/2024 in #💻┃support
[help] custom sign-up and sign-in pages
import { useKindeAuth } from '@kinde-oss/kinde-auth-react'
import { createFileRoute } from '@tanstack/react-router'
import { Heading } from '@zenif/react-web-components-v2'
import { useId } from 'react'
import { VStack } from '../../styled-system/jsx'
import { UiLink } from '../components/ui/link/UiLink'
import { SignInForm } from '../features/auth/sign-in/SignInForm'
import { appConfig } from '../shared/appConfig'

const Route = createFileRoute('/_anonymous/sign-in')({
component: SignInPage,
})

function SignInPage() {
const formId = useId()

const { login } = useKindeAuth()

return (
<VStack alignItems="center" justifyContent="center" rowGap="3">
<Heading as="h2" size="4xl" fontWeight="normal">
Sign in to <strong>ZENIF</strong> business portal
</Heading>
<SignInForm
id={formId}
onSubmit={(vars) => {
login({
authUrlParams: {
connection_id: appConfig.kinde.connectionIds.passwordless,
login_hint: vars.email,
},
})
}}
/>
<UiLink to="/sign-up">Don't have an account? Sign up.</UiLink>
</VStack>
)
}

export { Route }
import { useKindeAuth } from '@kinde-oss/kinde-auth-react'
import { createFileRoute } from '@tanstack/react-router'
import { Heading } from '@zenif/react-web-components-v2'
import { useId } from 'react'
import { VStack } from '../../styled-system/jsx'
import { UiLink } from '../components/ui/link/UiLink'
import { SignInForm } from '../features/auth/sign-in/SignInForm'
import { appConfig } from '../shared/appConfig'

const Route = createFileRoute('/_anonymous/sign-in')({
component: SignInPage,
})

function SignInPage() {
const formId = useId()

const { login } = useKindeAuth()

return (
<VStack alignItems="center" justifyContent="center" rowGap="3">
<Heading as="h2" size="4xl" fontWeight="normal">
Sign in to <strong>ZENIF</strong> business portal
</Heading>
<SignInForm
id={formId}
onSubmit={(vars) => {
login({
authUrlParams: {
connection_id: appConfig.kinde.connectionIds.passwordless,
login_hint: vars.email,
},
})
}}
/>
<UiLink to="/sign-up">Don't have an account? Sign up.</UiLink>
</VStack>
)
}

export { Route }
5 replies
KKinde
Created by Francisco "Klogan" Barros on 8/19/2024 in #💻┃support
[help] custom sign-up and sign-in pages
Hello 👋 @kinde-oss/[email protected]
Have you enable the "Use your own sign-up and sign-in screens"? Yes, I did.
Full relevant code is below (two files).
5 replies
KKinde
Created by Francisco "Klogan" Barros on 8/16/2024 in #💻┃support
[authentication] custom sign up using react
Alright Dan. Thank you. For the time being, I believe we are going with passwordless. For the amount of subscribers we will have in the start and given they will be working in close colaboration with us, it should not be an issue. 🙂 Following this one: https://www.youtube.com/watch?v=63IT5qlXJ64 😊 (but for react spa)
7 replies
KKinde
Created by Francisco "Klogan" Barros on 8/16/2024 in #💻┃support
[authentication] custom sign up using react
We will use social on the mobile app, when we eventually get there, but that would the B2C part.
7 replies
KKinde
Created by Francisco "Klogan" Barros on 8/16/2024 in #💻┃support
[authentication] custom sign up using react
Not really. It's B2B. We are creating restaurant management software with more contemporary features and friendlier ui/ux. Existing alternatives were written at least 20 years ago. I've used them in the past. 😛
7 replies
KKinde
Created by Francisco "Klogan" Barros on 8/16/2024 in #💻┃support
[authentication] custom sign up using react
We understand that passwordless is arguably more secure and a great commodity. However, the users we are targetting are not the most tech savy and are often a bit aged. So they are more used to the email + pwd model.
7 replies
KKinde
Created by Francisco "Klogan" Barros on 8/16/2024 in #💻┃support
[authentication] custom sign up using react
Would it be possible using a backend as a proxy somehow? Using the Java SDK
7 replies
KKinde
Created by Francisco "Klogan" Barros on 6/30/2024 in #💻┃support
[react-sdk][react-native-sdk (expo)] recommendation for integration testing mocks
Hey a toolset would be amazing, but a toolset would probably not be in your best interest on the long run because of the maintainability overhead (unless you already have such toolset being used internally, in which case it would be great for you share such utilities). However with so many languages plus testing tools within them it could grow complex real fast. Certainly such toolset would not be a do once and forget. It probably require ongoing updates. An alternative, would be to write up some documentation on how you would mock authentication and authorization, on a handful of your most used SDKs. Dunno, if React is one of them, but I can assume so. Example documentation section Testing your { React, React Native, Vue, Angular } UI user access with Kinde.
5 replies
KKinde
Created by Francisco "Klogan" Barros on 6/30/2024 in #💻┃support
[react-sdk][react-native-sdk (expo)] recommendation for integration testing mocks
Hey Hey, not really. Integration tests for jest; In the mean time I came to the conclusion that I might as well just mock the return type of useKindeAuth hook on React on certain unit and integration tests; That should be the easiest for me. However, would still appreciate an insider opinion. For E2E tests I'm using playwright for the web application and debox for the mobile application, so, I'm basically testing against real live browser/device applications and won't be using any mocked data. I will have a test user in Kinde for this purpose. The thing is, playwright and detox tests take time, so I won't be covering "all" cases in E2E.
5 replies