Skip to content

Commit 5fc174b

Browse files
authored
Client login fixes (#178)
* fix: fixed client 2FA * fix: added protected and roles to all routes * fix: fixed 2FA logic * fix: fixed user abbreviation on 2FA input page
1 parent 6b115c6 commit 5fc174b

File tree

8 files changed

+66
-682
lines changed

8 files changed

+66
-682
lines changed

client/src/App.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import VolunteersPage from "./components/volunteersPage/VolunteersPage";
4646
import { InitialScreenerTable } from "./components/initialScreener/initialScreenerTable";
4747
import CommentForm from "./components/initialScreener/commentForm";
4848
import {AdminFormsHub} from "./components/adminClientForms/adminFormsHub"
49-
import { Playground } from "./themes/play";
5049
import { ClientLandingPage, ChooseForm } from "./components/clientLandingPage/ClientLandingPage";
5150

5251
const App = () => {
@@ -142,7 +141,7 @@ const App = () => {
142141
/>
143142
<Route
144143
path="/admin-client-list"
145-
element={<AdminClientList />}
144+
element={<ProtectedRoute element={<AdminClientList />} allowedRoles={['admin']} />}
146145
/>
147146
<Route
148147
path="/accounts"
@@ -155,7 +154,7 @@ const App = () => {
155154
/>
156155
<Route
157156
path="/clientlist"
158-
element={<ClientList />}
157+
element={<ProtectedRoute element={<ClientList />} allowedRoles={['user']} />}
159158
/>
160159

161160
<Route
@@ -182,11 +181,11 @@ const App = () => {
182181
<Route
183182
path="/casemanager"
184183
element={<ProtectedRoute element={<CaseManager />} allowedRoles={['admin', 'user']} />}
184+
/>
185185

186186
<Route
187187
path="/random-client-survey/:language?"
188-
//element={<ProtectedRoute element={<RandomClientSurvey />} allowedRoles={['client']} />}
189-
element={<RandomClientSurvey/>}
188+
element={<ProtectedRoute element={<RandomClientSurvey />} allowedRoles={['client']} />}
190189
/>
191190
<Route
192191
path ="/frontDesk"
@@ -198,29 +197,28 @@ const App = () => {
198197
/>
199198
<Route
200199
path ="/personal/:language?"
201-
element = {<ProtectedRoute element={<PersonalInformation hidden={false}/>} />}
200+
element = {<ProtectedRoute element={<PersonalInformation hidden={false}/>} allowedRoles={['client']}/>}
202201
/>
203202
<Route
204203
path ="/financial/:language?"
205-
element ={<ProtectedRoute element={<FinancialInformation hidden={false}/>} />}
204+
element ={<ProtectedRoute element={<FinancialInformation hidden={false}/>} allowedRoles={['client']}/>}
206205
/>
207206
<Route
208207
path ="/health/:language?"
209-
element ={<ProtectedRoute element={<HealthSocialInformation hidden={false}/>}/>}
208+
element ={<ProtectedRoute element={<HealthSocialInformation hidden={false}/>} allowedRoles={['client']}/>}
210209
/>
211210
<Route
212211
path ="/additional/:language?"
213-
element ={<ProtectedRoute element={<AdditionalInformation hidden={false}/>}/>}
212+
element ={<ProtectedRoute element={<AdditionalInformation hidden={false}/>} allowedRoles={['client']}/>}
214213
/>
215214
<Route
216215
path ="/review/:language?"
217-
element ={<ProtectedRoute element={<ReviewInformation/>}/>}
216+
element ={<ProtectedRoute element={<ReviewInformation/>} allowedRoles={['client']}/>}
218217
/>
219218
<Route
220219
path ="/success/:language?"
221-
element ={<ProtectedRoute element={<Success/>} />}
220+
element ={<ProtectedRoute element={<Success/>} allowedRoles={['client']}/>}
222221
/>
223-
<Route path="/playground" element={<Playground/>}/>
224222
<Route
225223
path = "/initial-screener-table"
226224
element = {<ProtectedRoute element={<InitialScreenerTable />} allowedRoles={["user"]}/>}
@@ -231,11 +229,10 @@ const App = () => {
231229
/>
232230
<Route
233231
path = "/client-landing-page/:form"
234-
element = {<ClientLandingPage />} />
235-
<Route
232+
element = {<ProtectedRoute element={<ClientLandingPage />} allowedRoles={['client']} />} />
233+
<Route
236234
path = "/choose-form"
237-
element = {<ChooseForm />} />
238-
235+
element = {<ProtectedRoute element={<ChooseForm />} allowedRoles={['client']} />} />
239236
<Route
240237
path="/"
241238
element={

client/src/components/adminClientForms/FormTables/RandomClientTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export const RandomClientTable = () => {
338338
<FilterTemplate
339339
setFilterQuery={setFilterQuery}
340340
type={"randomSurvey"}
341-
/>
341+
/></HStack>
342342
<HStack
343343
justifyContent="space-between"
344344
>

client/src/components/adminClientForms/FormTables/SuccessStoryTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export const SuccessStoryTable = () => {
280280
<FilterTemplate
281281
setFilterQuery={setFilterQuery}
282282
type={"successStory"}
283-
/>
283+
/></HStack>
284284
<HStack
285285
justifyContent="space-between"
286286
>

client/src/components/authentification/authentification.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const Authentification = () => {
4848
const toast = useToast();
4949
const { userType } = useParams<{ userType: string }>();
5050
const { isOpen, onOpen, onClose } = useDisclosure();
51-
const userAbbreviation = userType === "Case Manager" ? "CM" : "AD";
51+
const userAbbreviation = userType === "Case Manager" ? "CM" : (userType === "Client" ? "CL": "AD");
5252

5353
const { handleRedirectResult, createCode, authenticate } = useAuthContext();
5454
const { backend } = useBackendContext();
@@ -68,6 +68,8 @@ export const Authentification = () => {
6868
}
6969
else if (userType === "Admin") {
7070
navigate("/admin-client-list");
71+
} else if (userType === "Client") {
72+
navigate("/choose-form");
7173
}
7274
} catch (error) {
7375
// toast({

0 commit comments

Comments
 (0)