mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 13:20:19 +08:00
fix: set initial value in CountryCodeSelect (#1890)
This commit is contained in:
@ -78,6 +78,7 @@ function CheckPasswordForm({user, onSuccess, onFail}) {
|
|||||||
|
|
||||||
export function MfaVerifyForm({mfaProps, application, user, onSuccess, onFail}) {
|
export function MfaVerifyForm({mfaProps, application, user, onSuccess, onFail}) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
mfaProps = mfaProps ?? {type: ""};
|
||||||
|
|
||||||
const onFinish = ({passcode}) => {
|
const onFinish = ({passcode}) => {
|
||||||
const data = {passcode, type: mfaProps.type, ...user};
|
const data = {passcode, type: mfaProps.type, ...user};
|
||||||
@ -97,9 +98,9 @@ export function MfaVerifyForm({mfaProps, application, user, onSuccess, onFail})
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mfaProps?.type === SmsMfaType) {
|
if (mfaProps.type === SmsMfaType) {
|
||||||
return <MfaSmsVerifyForm onFinish={onFinish} application={application} />;
|
return <MfaSmsVerifyForm onFinish={onFinish} application={application} />;
|
||||||
} else if (mfaProps?.type === TotpMfaType) {
|
} else if (mfaProps.type === TotpMfaType) {
|
||||||
return <MfaTotpVerifyForm onFinish={onFinish} mfaProps={mfaProps} />;
|
return <MfaTotpVerifyForm onFinish={onFinish} mfaProps={mfaProps} />;
|
||||||
} else {
|
} else {
|
||||||
return <div></div>;
|
return <div></div>;
|
||||||
@ -160,7 +161,7 @@ class MfaSetupPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState, snapshot) {
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
||||||
if (prevState.isAuthenticated === true && this.state.mfaProps === null) {
|
if (this.state.isAuthenticated === true && this.state.mfaProps === null) {
|
||||||
MfaBackend.MfaSetupInitiate({
|
MfaBackend.MfaSetupInitiate({
|
||||||
type: this.state.type,
|
type: this.state.type,
|
||||||
...this.getUser(),
|
...this.getUser(),
|
||||||
|
@ -17,10 +17,12 @@ import * as Setting from "../../Setting";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const CountryCodeSelect = (props) => {
|
export const CountryCodeSelect = (props) => {
|
||||||
const {onChange, style, disabled, value} = props;
|
const {onChange, style, disabled} = props;
|
||||||
const countryCodes = props.countryCodes ?? [];
|
const countryCodes = props.countryCodes ?? [];
|
||||||
|
const [value, setValue] = React.useState(countryCodes.length > 0 ? countryCodes[0] : "");
|
||||||
|
|
||||||
const handleOnChange = (value) => {
|
const handleOnChange = (value) => {
|
||||||
|
setValue(value);
|
||||||
onChange?.(value);
|
onChange?.(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user