Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/middleware/user.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function isAdminByEmail(req, res, next) {
return res.sendStatus(400);
} else {
const role = user.accessLevel;
if (role === 'admin' || user.managedProjects.length > 0) {
if (role === 'admin' || role === 'superadmin' || user.managedProjects.length > 0) {
next();
} else {
next(res.sendStatus(401));
Expand Down
2 changes: 1 addition & 1 deletion backend/routers/grantpermission.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ router.post("/gitHub", async (req, res) => {

const teamSlugs = [baseTeamSlug, managerTeamSlug];

if (accessLevel === "admin") teamSlugs.push(adminTeamSlug);
if (accessLevel === "admin" || accessLevel === "superadmin") teamSlugs.push(adminTeamSlug);

function createSlug(string) {
let slug = string.toLowerCase();
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Navbar = (props) => {
</>
)}
{/* Admin auth -> Displays 2 links -> 'Users' and 'Projects'. */}
{auth?.user?.accessLevel === 'admin' && (
{(auth?.user?.accessLevel === 'admin' || auth?.user?.accessLevel === 'superadmin') && (
<>
<StyledButton component={NavLink} to="/users">
USERS
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ProjectForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default function ProjectForm({
<Box sx={{ textAlign: 'center' }}>
<Typography variant="h1">Project Management</Typography>
</Box>
{auth.user.accessLevel === 'admin' ? (
{(auth.user.accessLevel === 'admin' || auth.user.accessLevel == 'superadmin' )? (
<TitledBox
title={editMode ? 'Editing Project' : 'Project Information'}
badge={isEdit ? editIcon() : addIcon()}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/manageProjects/editableField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const EditableField = ({
fieldType = 'text',
fieldTitle,
accessLevel,
canEdit = ['admin'],
canEdit = ['admin', 'superadmin'],
}) => {
const [fieldValue, setFieldValue] = useState(fieldData);
const [editable, setEditable] = useState(false);
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/manageProjects/selectProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const SelectProject = ({ projects, accessLevel, user }) => {
// If access level is 'user' display user managed projects.
const managedProjects = projects
?.filter((proj) => {
if (accessLevel === 'admin') {
if (accessLevel === 'admin' || accessLevel === 'superadmin') {
return proj.projectStatus === 'Active';
}

Expand All @@ -31,7 +31,7 @@ const SelectProject = ({ projects, accessLevel, user }) => {
<div className="container--ManageProjects">
<Typography variant="h3">Project Management</Typography>
<div className="project-sub-heading" style={{ margin: '0 auto' }}>
{accessLevel === 'admin' && (
{accessLevel === 'admin' || accessLevel === 'superadmin' && (
<Link to="/projects/create">
{' '}
<Button variant="secondary" sx={{ mb: 3 }}>
Expand Down
2 changes: 1 addition & 1 deletion client/src/context/authContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const fetchAuth = async () => {
return { user: null, isAdmin: false, isError: true };

const user = await response.json();
return { user, isAdmin: user.accessLevel === 'admin', isError: false };
return { user, isAdmin: (user.accessLevel === 'admin' || user.accessLevel === 'superadmin'), isError: false };
} catch (error) {
// this should never be hit...
console.error('fetchAuth - error', error);
Expand Down
6 changes: 3 additions & 3 deletions client/src/pages/ProjectList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export default function ProjectList({ auth }) {
async function fetchAllProjects() {
let projectData;

if(user?.accessLevel === 'admin') {
if(user?.accessLevel === 'admin' || user?.accessLevel === 'superadmin') {
projectData = await projectApiService.fetchProjects();
}

// if user is not admin, but is a project manager, only show projects they manage
if (user?.accessLevel !== 'admin' && user?.managedProjects.length > 0) {
if ((user?.accessLevel !== 'admin' || user?.accessLevel !== 'superadmin') && user?.managedProjects.length > 0) {
projectData = await projectApiService.fetchPMProjects(user.managedProjects);
}

Expand Down Expand Up @@ -80,7 +80,7 @@ export default function ProjectList({ auth }) {
</Typography>
</Box>

{user?.accessLevel === 'admin' && (
{(user?.accessLevel === 'admin' || user?.accessLevel === 'superadmin') && (
<Box sx={{ textAlign: 'center' }}>
<Button
component={Link}
Expand Down
2 changes: 2 additions & 0 deletions client/src/utils/authUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export function authLevelRedirect(user) {
let userAccessLevel = user.accessLevel;

switch (userAccessLevel) {
case 'superadmin':
loginRedirect = '/welcome'
case 'admin':
loginRedirect = '/welcome';
break;
Expand Down
Loading