107 lines
3.3 KiB
TypeScript
107 lines
3.3 KiB
TypeScript
// Metro module 14780 (f14781).
|
|
import { useState } from "react";
|
|
import { View } from "react-native";
|
|
import useWideAuthView from "../../../auth/native/useWideAuthView";
|
|
import MfaScreenUtils from "../MfaScreenUtils";
|
|
import MfaOptionScreen from "./MfaOptionScreen";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { TextInput } from "../../../../design/components/TextInput/native/TextInput.native";
|
|
import MFAButton from "../components/button";
|
|
export default function PasswordScreen(props) {
|
|
let setState, state, setState2, setState3, _sendPassword2;
|
|
const { mfaChallenge, finish } = props;
|
|
setState = void 0;
|
|
state = void 0;
|
|
setState2 = void 0;
|
|
setState3 = void 0;
|
|
const sendPassword = function sendPassword() {
|
|
return _sendPassword2.apply(this, arguments);
|
|
};
|
|
_sendPassword2 = function _sendPassword() {
|
|
const r9 = async () => {
|
|
let message, c30773_3;
|
|
let c30773_4 = 0;
|
|
let c31737_0;
|
|
L10: {
|
|
try {
|
|
setState(null);
|
|
setState2(true);
|
|
c30773_4 = 1;
|
|
await finish({
|
|
mfaType: "password",
|
|
data: state
|
|
});
|
|
(0, setState3)(true);
|
|
c30773_4 = 0;
|
|
(0, setState2)(false);
|
|
} catch ($e) {
|
|
const r25 = $e;
|
|
let r7 = r25;
|
|
c30773_3 = r25;
|
|
if (c30773_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r66 = c30773_3;
|
|
c30773_4 = 0;
|
|
c31737_0 = r66;
|
|
const message2 = c31737_0.body?.message;
|
|
message = message2;
|
|
if (message2 == null) {
|
|
message = c31737_0.message;
|
|
}
|
|
setState(message);
|
|
(0, setState2)(false);
|
|
break L10;
|
|
} catch (r62) {
|
|
r7 = r62;
|
|
c30773_3 = r62;
|
|
if (c30773_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
};
|
|
_sendPassword2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
const styles = MfaScreenUtils.useScreenStyles(useWideAuthView());
|
|
let errorMessage;
|
|
[errorMessage, setState] = useState(null);
|
|
let onChange;
|
|
[state, onChange] = useState("");
|
|
let loading;
|
|
[loading, setState2] = useState(false);
|
|
let state2;
|
|
[state2, setState3] = useState(false);
|
|
const props2 = {
|
|
headerText: intl.string(t.Rw1XuM),
|
|
input: <View style={styles.inputContainer}>
|
|
<TextInput autoFocus required textContentType="password" label={intl.string(t["CIGa+7"])} placeholder={intl.string(t["CIGa+7"])} autoComplete="current-password" errorMessage={errorMessage} returnKeyType="done" onChange={onChange} onSubmitEditing={sendPassword} isDisabled={loading ? loading : state2} isClearable secureTextEntry />
|
|
</View>,
|
|
submit: null,
|
|
screenProps: null,
|
|
mfaMethod: "password"
|
|
};
|
|
const props3 = {
|
|
text: intl.string(t.geKm7t),
|
|
disabled: (loading ? loading : state2) || state.length === 0,
|
|
loading: null,
|
|
onPress: null
|
|
};
|
|
if (!loading) {
|
|
loading = state2;
|
|
}
|
|
props3.loading = loading;
|
|
props3.onPress = sendPassword;
|
|
props2.submit = <MFAButton {...props3} />;
|
|
props2.screenProps = {
|
|
mfaChallenge,
|
|
finish
|
|
};
|
|
return <MfaOptionScreen {...props2} />;
|
|
};
|