Skip to content

Commit

Permalink
hide password page if sso user
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Dec 2, 2023
1 parent fc1179a commit f050b17
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
3 changes: 3 additions & 0 deletions apps/api/src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ export function authRoutes(fastify: FastifyInstance) {
});
}

const config = await prisma.config.findFirst();

const data = {
id: user!.id,
email: user!.email,
Expand All @@ -305,6 +307,7 @@ export function authRoutes(fastify: FastifyInstance) {
ticket_status_changed: user!.notify_ticket_status_changed,
ticket_comments: user!.notify_ticket_comments,
ticket_assigned: user!.notify_ticket_assigned,
sso_status: config!.sso_active,
};

reply.send({
Expand Down
55 changes: 28 additions & 27 deletions apps/client/layouts/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { useState } from "react";

import useTranslation from "next-translate/useTranslation";
import Link from "next/link";
import { useRouter } from "next/router";
import { useUser } from "../store/session";

export default function Settings({ children }) {
const router = useRouter();

const { t } = useTranslation("peppermint");
const { user } = useUser();

const linkStyles = {
active:
"w-full bg-teal-50 border-teal-500 text-teal-700 hover:bg-teal-50 hover:text-teal-700 group border-l-4 px-3 py-2 flex items-center text-sm font-medium",
inactive:
"w-full border-transparent text-gray-900 hover:bg-gray-50 hover:text-gray-900 group mt-1 border-l-4 px-3 py-2 flex items-center text-sm font-medium",
};
const [show, setShow] = useState("profile");

return (
<div>
Expand Down Expand Up @@ -78,31 +77,33 @@ export default function Settings({ children }) {
<span className="truncate">{t("notifications")}</span>
</Link>

<Link
href="/settings/password"
className={
router.pathname === "/settings/password"
? linkStyles.active
: linkStyles.inactive
}
>
<svg
className=" flex-shrink-0 -ml-1 mr-3 h-6 w-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
aria-hidden="true"
{user.sso_active && (
<Link
href="/settings/password"
className={
router.pathname === "/settings/password"
? linkStyles.active
: linkStyles.inactive
}
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"
/>
</svg>
<span className="truncate">{t("reset_password")}</span>
</Link>
<svg
className=" flex-shrink-0 -ml-1 mr-3 h-6 w-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"
/>
</svg>
<span className="truncate">{t("reset_password")}</span>
</Link>
)}
</nav>
</aside>

Expand Down

0 comments on commit f050b17

Please sign in to comment.