mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add OAuth2 authentication (#147)
- Added Site settings > Authentication section - Create/edit/delete your custom oauth2 configurations - Login or signup with oauth2
This commit is contained in:
committed by
GitHub
parent
3bda6dee08
commit
4c73b398e8
@@ -8,6 +8,7 @@ import Spinner from '../common/Spinner';
|
||||
import { DangerText } from '../common/CustomTexts';
|
||||
import { ITenantSignUpTenantForm } from './TenantSignUpP';
|
||||
import HttpStatus from '../../constants/http_status';
|
||||
import { getLabel, getValidationMessage } from '../../helpers/formUtils';
|
||||
|
||||
interface Props {
|
||||
isSubmitting: boolean;
|
||||
@@ -34,11 +35,11 @@ const TenantSignUpForm = ({
|
||||
<input
|
||||
{...register('siteName', { required: true })}
|
||||
autoFocus
|
||||
placeholder={I18n.t('signup.step2.site_name')}
|
||||
placeholder={getLabel('tenant', 'site_name')}
|
||||
id="tenantSiteName"
|
||||
className="formControl"
|
||||
/>
|
||||
<DangerText>{errors.siteName && I18n.t('signup.step2.validations.site_name')}</DangerText>
|
||||
<DangerText>{errors.siteName?.type === 'required' && getValidationMessage('required', 'tenant', 'site_name')}</DangerText>
|
||||
</div>
|
||||
|
||||
<div className="formRow">
|
||||
@@ -51,7 +52,7 @@ const TenantSignUpForm = ({
|
||||
return res.status === HttpStatus.OK;
|
||||
},
|
||||
})}
|
||||
placeholder={I18n.t('signup.step2.subdomain')}
|
||||
placeholder={getLabel('tenant', 'subdomain')}
|
||||
id="tenantSubdomain"
|
||||
className="formControl"
|
||||
/>
|
||||
@@ -60,7 +61,7 @@ const TenantSignUpForm = ({
|
||||
</div>
|
||||
</div>
|
||||
<DangerText>
|
||||
{errors.subdomain?.type === 'required' && I18n.t('signup.step2.validations.subdomain')}
|
||||
{errors.subdomain?.type === 'required' && getValidationMessage('required', 'tenant', 'subdomain')}
|
||||
</DangerText>
|
||||
<DangerText>
|
||||
{errors.subdomain?.type === 'validate' && I18n.t('signup.step2.validations.subdomain_already_taken')}
|
||||
|
||||
@@ -6,6 +6,8 @@ import Box from '../common/Box';
|
||||
import Button from '../common/Button';
|
||||
import { ITenantSignUpUserForm } from './TenantSignUpP';
|
||||
import { DangerText } from '../common/CustomTexts';
|
||||
import { getLabel, getValidationMessage } from '../../helpers/formUtils';
|
||||
import { EMAIL_REGEX } from '../../constants/regex';
|
||||
|
||||
interface Props {
|
||||
currentStep: number;
|
||||
@@ -24,7 +26,13 @@ const UserSignUpForm = ({
|
||||
userData,
|
||||
setUserData,
|
||||
}: Props) => {
|
||||
const { register, handleSubmit, setError, formState: { errors } } = useForm<ITenantSignUpUserForm>();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
setError,
|
||||
getValues,
|
||||
formState: { errors }
|
||||
} = useForm<ITenantSignUpUserForm>();
|
||||
const onSubmit: SubmitHandler<ITenantSignUpUserForm> = data => {
|
||||
if (data.password !== data.passwordConfirmation) {
|
||||
setError('passwordConfirmation', I18n.t('signup.step1.validations.password_mismatch'));
|
||||
@@ -53,22 +61,25 @@ const UserSignUpForm = ({
|
||||
<input
|
||||
{...register('fullName', { required: true, minLength: 2 })}
|
||||
autoFocus
|
||||
placeholder={I18n.t('common.forms.auth.full_name')}
|
||||
placeholder={getLabel('user', 'full_name')}
|
||||
id="userFullName"
|
||||
className="formControl"
|
||||
/>
|
||||
<DangerText>{ errors.fullName && I18n.t('signup.step1.validations.full_name') }</DangerText>
|
||||
<DangerText>{errors.fullName && getValidationMessage('required', 'user', 'full_name')}</DangerText>
|
||||
</div>
|
||||
|
||||
<div className="formRow">
|
||||
<input
|
||||
{...register('email', { required: true, pattern: /(.+)@(.+){2,}\.(.+){2,}/ })}
|
||||
{...register('email', { required: true, pattern: EMAIL_REGEX })}
|
||||
type="email"
|
||||
placeholder={I18n.t('common.forms.auth.email')}
|
||||
placeholder={getLabel('user', 'email')}
|
||||
id="userEmail"
|
||||
className="formControl"
|
||||
/>
|
||||
<DangerText>{ errors.email && I18n.t('signup.step1.validations.email') }</DangerText>
|
||||
<DangerText>{errors.email?.type === 'required' && getValidationMessage('required', 'user', 'email')}</DangerText>
|
||||
<DangerText>
|
||||
{errors.email?.type === 'pattern' && I18n.t('common.validations.email')}
|
||||
</DangerText>
|
||||
</div>
|
||||
|
||||
<div className="formRow">
|
||||
@@ -76,22 +87,22 @@ const UserSignUpForm = ({
|
||||
<input
|
||||
{...register('password', { required: true, minLength: 6, maxLength: 128 })}
|
||||
type="password"
|
||||
placeholder={I18n.t('common.forms.auth.password')}
|
||||
placeholder={getLabel('user', 'password')}
|
||||
id="userPassword"
|
||||
className="formControl"
|
||||
/>
|
||||
<DangerText>{ errors.password && I18n.t('signup.step1.validations.password', { n: 6 }) }</DangerText>
|
||||
<DangerText>{ errors.password && I18n.t('common.validations.password', { n: 6 }) }</DangerText>
|
||||
</div>
|
||||
|
||||
<div className="formGroup col-6">
|
||||
<input
|
||||
{...register('passwordConfirmation')}
|
||||
type="password"
|
||||
placeholder={I18n.t('common.forms.auth.password_confirmation')}
|
||||
placeholder={getLabel('user', 'password_confirmation')}
|
||||
id="userPasswordConfirmation"
|
||||
className="formControl"
|
||||
/>
|
||||
<DangerText>{ errors.passwordConfirmation && I18n.t('signup.step1.validations.password_mismatch') }</DangerText>
|
||||
<DangerText>{ errors.passwordConfirmation && I18n.t('common.validations.password_mismatch') }</DangerText>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user