mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
login logout redirects, session, remove out of scope code
This commit is contained in:
@ -27,10 +27,10 @@ const userNavigation = [
|
||||
{ name: "Your Profile", href: "/settings" },
|
||||
{
|
||||
name: "Sign out",
|
||||
href: "/login",
|
||||
href: "",
|
||||
click: (e: any) => {
|
||||
e.preventDefault();
|
||||
signOut();
|
||||
signOut({ callbackUrl: "/login" });
|
||||
},
|
||||
},
|
||||
];
|
||||
@ -41,7 +41,6 @@ function classNames(...classes: any) {
|
||||
|
||||
export default function Layout({ children }: any) {
|
||||
const router = useRouter();
|
||||
|
||||
navigation.forEach((element) => {
|
||||
element.current = element.href == router.route;
|
||||
});
|
||||
|
||||
@ -80,7 +80,7 @@ export default function Example() {
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
signIn();
|
||||
signIn(undefined, { callbackUrl: "/dashboard" });
|
||||
}}
|
||||
className="group relative flex w-full justify-center rounded-md border border-transparent bg-neon py-2 px-4 text-sm font-medium text-white hover:bg-neon-dark focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
|
||||
>
|
||||
|
||||
@ -96,52 +96,6 @@ export default function Setttings() {
|
||||
</div>
|
||||
|
||||
<div className="mt-6 flex flex-col lg:flex-row">
|
||||
<div className="flex-grow space-y-6">
|
||||
<div>
|
||||
<label
|
||||
htmlFor="username"
|
||||
className="block text-sm font-medium text-gray-700"
|
||||
>
|
||||
Username
|
||||
</label>
|
||||
<div className="mt-1 flex rounded-md shadow-sm">
|
||||
<span className="inline-flex items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-3 text-gray-500 sm:text-sm">
|
||||
workcation.com/
|
||||
</span>
|
||||
<input
|
||||
type="text"
|
||||
name="username"
|
||||
id="username"
|
||||
autoComplete="username"
|
||||
className="block w-full min-w-0 flex-grow rounded-none rounded-r-md border-gray-300 focus:border-sky-500 focus:ring-sky-500 sm:text-sm"
|
||||
defaultValue={user.handle}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
htmlFor="about"
|
||||
className="block text-sm font-medium text-gray-700"
|
||||
>
|
||||
About
|
||||
</label>
|
||||
<div className="mt-1">
|
||||
<textarea
|
||||
id="about"
|
||||
name="about"
|
||||
rows={3}
|
||||
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-sky-500 focus:ring-sky-500 sm:text-sm"
|
||||
defaultValue={""}
|
||||
/>
|
||||
</div>
|
||||
<p className="mt-2 text-sm text-gray-500">
|
||||
Brief description for your profile. URLs are
|
||||
hyperlinked.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 flex-grow lg:mt-0 lg:ml-6 lg:flex-shrink-0 lg:flex-grow-0">
|
||||
<p
|
||||
className="text-sm font-medium text-gray-700"
|
||||
@ -237,21 +191,6 @@ export default function Setttings() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="col-span-12">
|
||||
<label
|
||||
htmlFor="url"
|
||||
className="block text-sm font-medium text-gray-700"
|
||||
>
|
||||
URL
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="url"
|
||||
id="url"
|
||||
className="mt-1 block w-full rounded-md border border-gray-300 py-2 px-3 shadow-sm focus:border-sky-500 focus:outline-none focus:ring-sky-500 sm:text-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="col-span-12 sm:col-span-6">
|
||||
<label
|
||||
htmlFor="company"
|
||||
@ -317,108 +256,6 @@ export default function Setttings() {
|
||||
/>
|
||||
</Switch>
|
||||
</Switch.Group>
|
||||
<Switch.Group
|
||||
as="li"
|
||||
className="flex items-center justify-between py-4"
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<Switch.Label
|
||||
as="p"
|
||||
className="text-sm font-medium text-gray-900"
|
||||
passive
|
||||
>
|
||||
Make account private
|
||||
</Switch.Label>
|
||||
<Switch.Description className="text-sm text-gray-500">
|
||||
Pharetra morbi dui mi mattis tellus sollicitudin
|
||||
cursus pharetra.
|
||||
</Switch.Description>
|
||||
</div>
|
||||
<Switch
|
||||
checked={privateAccount}
|
||||
onChange={setPrivateAccount}
|
||||
className={classNames(
|
||||
privateAccount ? "bg-teal-500" : "bg-gray-200",
|
||||
"relative ml-4 inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-sky-500 focus:ring-offset-2"
|
||||
)}
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={classNames(
|
||||
privateAccount ? "translate-x-5" : "translate-x-0",
|
||||
"inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
|
||||
)}
|
||||
/>
|
||||
</Switch>
|
||||
</Switch.Group>
|
||||
<Switch.Group
|
||||
as="li"
|
||||
className="flex items-center justify-between py-4"
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<Switch.Label
|
||||
as="p"
|
||||
className="text-sm font-medium text-gray-900"
|
||||
passive
|
||||
>
|
||||
Allow commenting
|
||||
</Switch.Label>
|
||||
<Switch.Description className="text-sm text-gray-500">
|
||||
Integer amet, nunc hendrerit adipiscing nam. Elementum
|
||||
ame
|
||||
</Switch.Description>
|
||||
</div>
|
||||
<Switch
|
||||
checked={allowCommenting}
|
||||
onChange={setAllowCommenting}
|
||||
className={classNames(
|
||||
allowCommenting ? "bg-teal-500" : "bg-gray-200",
|
||||
"relative ml-4 inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-sky-500 focus:ring-offset-2"
|
||||
)}
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={classNames(
|
||||
allowCommenting ? "translate-x-5" : "translate-x-0",
|
||||
"inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
|
||||
)}
|
||||
/>
|
||||
</Switch>
|
||||
</Switch.Group>
|
||||
<Switch.Group
|
||||
as="li"
|
||||
className="flex items-center justify-between py-4"
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<Switch.Label
|
||||
as="p"
|
||||
className="text-sm font-medium text-gray-900"
|
||||
passive
|
||||
>
|
||||
Allow mentions
|
||||
</Switch.Label>
|
||||
<Switch.Description className="text-sm text-gray-500">
|
||||
Adipiscing est venenatis enim molestie commodo eu
|
||||
gravid
|
||||
</Switch.Description>
|
||||
</div>
|
||||
<Switch
|
||||
checked={allowMentions}
|
||||
onChange={setAllowMentions}
|
||||
className={classNames(
|
||||
allowMentions ? "bg-teal-500" : "bg-gray-200",
|
||||
"relative ml-4 inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-sky-500 focus:ring-offset-2"
|
||||
)}
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={classNames(
|
||||
allowMentions ? "translate-x-5" : "translate-x-0",
|
||||
"inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
|
||||
)}
|
||||
/>
|
||||
</Switch>
|
||||
</Switch.Group>
|
||||
</ul>
|
||||
</div>
|
||||
<div className="mt-4 flex justify-end py-4 px-4 sm:px-6">
|
||||
|
||||
@ -2,6 +2,7 @@ import "../styles/tailwind.css";
|
||||
import { ReactElement, ReactNode } from "react";
|
||||
import type { AppProps } from "next/app";
|
||||
import { NextPage } from "next";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
|
||||
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
|
||||
getLayout?: (page: ReactElement) => ReactNode;
|
||||
@ -11,7 +12,14 @@ type AppPropsWithLayout = AppProps & {
|
||||
Component: NextPageWithLayout;
|
||||
};
|
||||
|
||||
export default function App({ Component, pageProps }: AppPropsWithLayout) {
|
||||
export default function App({
|
||||
Component,
|
||||
pageProps: { session, ...pageProps },
|
||||
}: AppPropsWithLayout) {
|
||||
const getLayout = Component.getLayout || ((page: any) => page);
|
||||
return getLayout(<Component {...pageProps} />);
|
||||
return getLayout(
|
||||
<SessionProvider session={session}>
|
||||
<Component {...pageProps} />{" "}
|
||||
</SessionProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -4,8 +4,8 @@ import GitHubProvider from "next-auth/providers/github";
|
||||
export default NextAuth({
|
||||
providers: [
|
||||
GitHubProvider({
|
||||
clientId: "",
|
||||
clientSecret: "",
|
||||
clientId: "df804870b0d11b0779cf",
|
||||
clientSecret: "7ef4bbc0957e48e4e6e59c5b5879b3d75d90acc5",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
@ -1,14 +1,20 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import type { ReactElement } from "react";
|
||||
import Layout from "../components/layout";
|
||||
import Settings from "../components/settings";
|
||||
import type { NextPageWithLayout } from "./_app";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
|
||||
const DocumentsPage: NextPageWithLayout = () => {
|
||||
const { data: session } = useSession();
|
||||
|
||||
console.log("Session:" + JSON.stringify(session));
|
||||
|
||||
const TeamPage: NextPageWithLayout = () => {
|
||||
return <>This is the documents page</>;
|
||||
};
|
||||
|
||||
TeamPage.getLayout = function getLayout(page: ReactElement) {
|
||||
DocumentsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return <Layout>{page}</Layout>;
|
||||
};
|
||||
|
||||
export default TeamPage;
|
||||
export default DocumentsPage;
|
||||
|
||||
Reference in New Issue
Block a user