From 26a0151b9c805c3b474442976ea967a842d3cd24 Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Tue, 9 Mar 2021 23:47:36 +0800 Subject: [PATCH] Set thu-learn-lib credential provider after login to keep session always alive --- src/App.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 544c3247..a42ee965 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -71,6 +71,7 @@ import {login} from 'data/actions/auth'; import {getAllSemesters, getCurrentSemester} from 'data/actions/semesters'; import {resetLoading} from 'data/actions/root'; import {getCoursesForSemester} from 'data/actions/courses'; +import {setCredentials} from 'data/source'; import AssignmentSubmission from 'screens/AssignmentSubmission'; import DeviceInfo from 'constants/DeviceInfo'; import TextButton from 'components/TextButton'; @@ -372,6 +373,7 @@ const MainTab = () => { const dispatch = useDispatch(); const loggedIn = useTypedSelector((state) => state.auth.loggedIn); + const auth = useTypedSelector((state) => state.auth); const currentSemester = useTypedSelector((state) => state.semesters.current); const semesters = useTypedSelector((state) => state.semesters.items); const newChangelog = useTypedSelector( @@ -381,6 +383,12 @@ const MainTab = () => { const windowSize = useWindowDimensions(); + useEffect(() => { + if (loggedIn && auth.username && auth.password) { + setCredentials(auth.username, auth.password); + } + }, [auth.password, auth.username, loggedIn]); + useEffect(() => { if (!loggedIn) { return;