|
|
@ -22,16 +22,20 @@ import LoadingIndicator from "./widgets/LoadingIndicator";
|
|
|
|
export default function LoginGate() {
|
|
|
|
export default function LoginGate() {
|
|
|
|
const credentials = useCredentials();
|
|
|
|
const credentials = useCredentials();
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
const [loading, setLoading] = React.useState(false);
|
|
|
|
const [fetchError, setFetchError] = React.useState<Error>();
|
|
|
|
const [fetchError, setFetchError] = React.useState<Error>();
|
|
|
|
|
|
|
|
|
|
|
|
async function onFormSubmit(username: string, password: string, serviceApiUrl?: string) {
|
|
|
|
async function onFormSubmit(username: string, password: string, serviceApiUrl?: string) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
setLoading(true);
|
|
|
|
setFetchError(undefined);
|
|
|
|
setFetchError(undefined);
|
|
|
|
const ret = login(username, password, serviceApiUrl);
|
|
|
|
const ret = login(username, password, serviceApiUrl);
|
|
|
|
await ret.payload;
|
|
|
|
await ret.payload;
|
|
|
|
dispatch(ret);
|
|
|
|
dispatch(ret);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
setFetchError(e);
|
|
|
|
setFetchError(e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
setLoading(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -56,6 +60,7 @@ export default function LoginGate() {
|
|
|
|
<h2>Please Log In</h2>
|
|
|
|
<h2>Please Log In</h2>
|
|
|
|
<LoginForm
|
|
|
|
<LoginForm
|
|
|
|
onSubmit={onFormSubmit}
|
|
|
|
onSubmit={onFormSubmit}
|
|
|
|
|
|
|
|
loading={loading}
|
|
|
|
error={fetchError}
|
|
|
|
error={fetchError}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<hr style={style.divider} />
|
|
|
|
<hr style={style.divider} />
|
|
|
|