-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HOSTSD-209 Fix all servers and auth bugs (#55)
- Loading branch information
Showing
16 changed files
with
120 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
'use client'; | ||
|
||
import { useSecureRoute } from '@/hooks'; | ||
import { useAuth } from '@/hooks'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
useSecureRoute((state) => state.isOrganizationAdmin, '/'); | ||
const state = useAuth(); | ||
|
||
// Only allow Organization Admin role to view this page. | ||
if (state.status === 'loading') return <div>Loading...</div>; | ||
if (!state.isOrganizationAdmin) redirect('/'); | ||
|
||
return <div>Client Admin</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
'use client'; | ||
|
||
import { useSecureRoute } from '@/hooks'; | ||
import { useAuth } from '@/hooks'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
useSecureRoute((state) => state.isOrganizationAdmin, '/'); | ||
const state = useAuth(); | ||
|
||
// Only allow Organization Admin role to view this page. | ||
if (state.status === 'loading') return <div>Loading...</div>; | ||
if (!state.isOrganizationAdmin) redirect('/'); | ||
|
||
return <div>Client User Admin</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
'use client'; | ||
|
||
import { Dashboard } from '@/components'; | ||
import { useSecureRoute } from '@/hooks'; | ||
import { useAuth } from '@/hooks'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
useSecureRoute((state) => state.isClient, '/'); | ||
const state = useAuth(); | ||
|
||
// Only allow Client role to view this page. | ||
if (state.status === 'loading') return <div>Loading...</div>; | ||
if (!state.isClient) redirect('/'); | ||
|
||
return <Dashboard />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
'use client'; | ||
|
||
import { AllocationTable, Col } from '@/components'; | ||
import { useSecureRoute } from '@/hooks'; | ||
import { useFilteredOrganizations, useFilteredServerItems } from '@/hooks/filter'; | ||
import { useAuth } from '@/hooks'; | ||
import { useServerItems } from '@/hooks/data'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
useSecureRoute((state) => state.isClient, '/'); | ||
const state = useAuth(); | ||
const { isReady, serverItems } = useServerItems(); | ||
|
||
const { organizations } = useFilteredOrganizations(); | ||
const { serverItems } = useFilteredServerItems(); | ||
// Only allow Client role to view this page. | ||
if (state.status === 'loading') return <div>Loading...</div>; | ||
if (!state.isClient) redirect('/'); | ||
|
||
return ( | ||
<Col> | ||
<h1>All Servers</h1> | ||
<AllocationTable operatingSystem={''} serverItems={serverItems} /> | ||
<AllocationTable serverItems={serverItems} loading={!isReady} /> | ||
</Col> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
'use client'; | ||
|
||
import { useSecureRoute } from '@/hooks'; | ||
import { useAuth } from '@/hooks'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
useSecureRoute((state) => state.isSystemAdmin, '/'); | ||
const state = useAuth(); | ||
|
||
// Only allow System Admin role to view this page. | ||
if (state.status === 'loading') return <div>Loading...</div>; | ||
if (!state.isSystemAdmin) redirect('/'); | ||
|
||
return <div>HSB Organization Admin</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
'use client'; | ||
|
||
import { useAuth } from '@/hooks'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
const state = useAuth(); | ||
|
||
// Only allow System Admin role to view this page. | ||
if (state.status === 'loading') return <div>Loading...</div>; | ||
if (!state.isSystemAdmin) redirect('/'); | ||
|
||
return <div>HSB Admin</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
'use client'; | ||
|
||
import { Dashboard } from '@/components'; | ||
import { useSecureRoute } from '@/hooks'; | ||
import { useAuth } from '@/hooks'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
useSecureRoute((state) => state.isHSB, '/'); | ||
const state = useAuth(); | ||
|
||
// Only allow HSB role to view this page. | ||
if (state.status === 'loading') return <div>Loading...</div>; | ||
if (!state.isHSB) redirect('/'); | ||
|
||
return <Dashboard />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
'use client'; | ||
|
||
import { AllocationTable, Col } from '@/components'; | ||
import { useSecureRoute } from '@/hooks'; | ||
import { useFilteredOrganizations, useFilteredServerItems } from '@/hooks/filter'; | ||
import { useAuth } from '@/hooks'; | ||
import { useServerItems } from '@/hooks/data'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
useSecureRoute((state) => state.isHSB, '/'); | ||
const state = useAuth(); | ||
const { isReady, serverItems } = useServerItems(); | ||
|
||
const { organizations } = useFilteredOrganizations(); | ||
const { serverItems } = useFilteredServerItems(); | ||
// Only allow HSB role to view this page. | ||
if (state.status === 'loading') return <div>Loading...</div>; | ||
if (!state.isHSB) redirect('/'); | ||
|
||
return ( | ||
<Col> | ||
<h1>All Servers</h1> | ||
<AllocationTable operatingSystem={''} serverItems={serverItems} /> | ||
<AllocationTable serverItems={serverItems} loading={!isReady} /> | ||
</Col> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './api'; | ||
export * from './constants'; | ||
export * from './useAuth'; | ||
export * from './useSecureRoute'; |
This file was deleted.
Oops, something went wrong.