fix(client): allow sign up

This commit is contained in:
chenos 2022-04-06 10:58:21 +08:00
parent 1dc8a21cfe
commit f7735ccce3
2 changed files with 13 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import { ISchema, useForm } from '@formily/react';
import { uid } from '@formily/shared'; import { uid } from '@formily/shared';
import React from 'react'; import React from 'react';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { SchemaComponent, useAPIClient, useCurrentDocumentTitle } from '..'; import { SchemaComponent, useAPIClient, useCurrentDocumentTitle, useSystemSettings } from '..';
const schema: ISchema = { const schema: ISchema = {
type: 'object', type: 'object',
@ -45,6 +45,7 @@ const schema: ISchema = {
link: { link: {
type: 'void', type: 'void',
'x-component': 'div', 'x-component': 'div',
'x-visible': '{{allowSignUp}}',
properties: { properties: {
link: { link: {
title: '{{t("Create an account")}}', title: '{{t("Create an account")}}',
@ -78,9 +79,12 @@ const useSignin = () => {
export const SigninPage = () => { export const SigninPage = () => {
useCurrentDocumentTitle('Signin'); useCurrentDocumentTitle('Signin');
const ctx = useSystemSettings();
const allowSignUp = ctx?.data?.data?.allowSignUp;
console.log('ctx.data.allowSignUp', ctx?.data?.data?.allowSignUp);
return ( return (
<div> <div>
<SchemaComponent scope={{ useSignin }} schema={schema} /> <SchemaComponent scope={{ useSignin, allowSignUp }} schema={schema} />
</div> </div>
); );
}; };

View File

@ -2,8 +2,8 @@ import { ISchema, useForm } from '@formily/react';
import { uid } from '@formily/shared'; import { uid } from '@formily/shared';
import { message } from 'antd'; import { message } from 'antd';
import React from 'react'; import React from 'react';
import { useHistory } from 'react-router-dom'; import { Redirect, useHistory } from 'react-router-dom';
import { SchemaComponent, useAPIClient, useCurrentDocumentTitle } from '..'; import { SchemaComponent, useAPIClient, useCurrentDocumentTitle, useSystemSettings } from '..';
const schema: ISchema = { const schema: ISchema = {
type: 'object', type: 'object',
@ -105,5 +105,10 @@ const useSignup = () => {
export const SignupPage = () => { export const SignupPage = () => {
useCurrentDocumentTitle('Signup'); useCurrentDocumentTitle('Signup');
const ctx = useSystemSettings();
const allowSignUp = ctx?.data?.data?.allowSignUp;
if (!allowSignUp) {
return <Redirect to={'/signin'} />;
}
return <SchemaComponent schema={schema} scope={{ useSignup }} />; return <SchemaComponent schema={schema} scope={{ useSignup }} />;
}; };