mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-30 00:50:48 +08:00
Fix passwordless user for new registrations (#2605)
This commit is contained in:
parent
21ba4e6e6c
commit
c016835208
@ -46,8 +46,13 @@ export const RegisterPage: FC = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
usePageTitle(t("action.register"));
|
usePageTitle(t("action.register"));
|
||||||
|
|
||||||
const { loading, authenticated, passwordlessUser, client, setClient } =
|
const {
|
||||||
useClientLegacy();
|
loading,
|
||||||
|
authenticated,
|
||||||
|
passwordlessUser: previousClientPasswordlessUser,
|
||||||
|
client: previousClient,
|
||||||
|
setClient,
|
||||||
|
} = useClientLegacy();
|
||||||
|
|
||||||
const confirmPasswordRef = useRef<HTMLInputElement>(null);
|
const confirmPasswordRef = useRef<HTMLInputElement>(null);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@ -56,7 +61,7 @@ export const RegisterPage: FC = () => {
|
|||||||
const [error, setError] = useState<Error>();
|
const [error, setError] = useState<Error>();
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [passwordConfirmation, setPasswordConfirmation] = useState("");
|
const [passwordConfirmation, setPasswordConfirmation] = useState("");
|
||||||
const { recaptchaKey, register } = useInteractiveRegistration(client);
|
const { recaptchaKey, register } = useInteractiveRegistration(previousClient);
|
||||||
const { execute, reset, recaptchaId } = useRecaptcha(recaptchaKey);
|
const { execute, reset, recaptchaId } = useRecaptcha(recaptchaKey);
|
||||||
|
|
||||||
const onSubmitRegisterForm = useCallback(
|
const onSubmitRegisterForm = useCallback(
|
||||||
@ -78,12 +83,16 @@ export const RegisterPage: FC = () => {
|
|||||||
password,
|
password,
|
||||||
userName,
|
userName,
|
||||||
recaptchaResponse,
|
recaptchaResponse,
|
||||||
passwordlessUser,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (client && client?.groupCallEventHandler && passwordlessUser) {
|
if (
|
||||||
|
previousClient &&
|
||||||
|
previousClient?.groupCallEventHandler &&
|
||||||
|
previousClientPasswordlessUser
|
||||||
|
) {
|
||||||
// Migrate the user's rooms
|
// Migrate the user's rooms
|
||||||
for (const groupCall of client.groupCallEventHandler.groupCalls.values()) {
|
for (const groupCall of previousClient.groupCallEventHandler.groupCalls.values()) {
|
||||||
const roomId = groupCall.room.roomId;
|
const roomId = groupCall.room.roomId;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -130,10 +139,10 @@ export const RegisterPage: FC = () => {
|
|||||||
register,
|
register,
|
||||||
location,
|
location,
|
||||||
history,
|
history,
|
||||||
passwordlessUser,
|
previousClientPasswordlessUser,
|
||||||
reset,
|
reset,
|
||||||
execute,
|
execute,
|
||||||
client,
|
previousClient,
|
||||||
setClient,
|
setClient,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -149,10 +158,21 @@ export const RegisterPage: FC = () => {
|
|||||||
}, [password, passwordConfirmation, t]);
|
}, [password, passwordConfirmation, t]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading && authenticated && !passwordlessUser && !registering) {
|
if (
|
||||||
|
!loading &&
|
||||||
|
authenticated &&
|
||||||
|
!previousClientPasswordlessUser &&
|
||||||
|
!registering
|
||||||
|
) {
|
||||||
history.push("/");
|
history.push("/");
|
||||||
}
|
}
|
||||||
}, [loading, history, authenticated, passwordlessUser, registering]);
|
}, [
|
||||||
|
loading,
|
||||||
|
history,
|
||||||
|
authenticated,
|
||||||
|
previousClientPasswordlessUser,
|
||||||
|
registering,
|
||||||
|
]);
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <LoadingView />;
|
return <LoadingView />;
|
||||||
|
Loading…
Reference in New Issue
Block a user