updatd logout links and login flow for nextauth

This commit is contained in:
2022-04-19 12:25:13 +01:00
parent 511a5ed98d
commit 3b1a49e561
9 changed files with 81 additions and 45 deletions
+2 -2
View File
@@ -195,7 +195,7 @@ const RegisterForm = (props) => {
)}
/>
<Field
{/* <Field
name="pinswg_custom_password"
id="pinswg_custom_password"
component={RenderTextfield}
@@ -226,7 +226,7 @@ const RegisterForm = (props) => {
errorMsg={t(
"account:register-new-account-confirm-password-label-errormsg"
)}
/>
/> */}
</fieldset>
<fieldset className="govuk-fieldset">
<legend className="govuk-fieldset__legend govuk-fieldset__legend--m">
+18
View File
@@ -741,6 +741,24 @@ const Breadcrumbs = (props) => {
) : (
""
)}
{router.pathname == "/auth/signin" ? (
<>
<li className="govuk-breadcrumbs__list-item">
Sign in
</li>
</>
) : (
""
)}
{router.pathname == "/auth/verify-request" ? (
<>
<li className="govuk-breadcrumbs__list-item">
Check your email
</li>
</>
) : (
""
)}
{/* {!_.isEmpty(slug) ? (
<>
<li className="govuk-breadcrumbs__list-item">
+8 -1
View File
@@ -7,6 +7,9 @@ import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import { setLogout } from "../store/accountDetails/action";
import _ from "lodash";
import { parseCookies, setCookie, destroyCookie } from "nookies";
import { useSession, signIn, signOut } from "next-auth/react";
const Header = (props) => {
let { t, lang } = useTranslation();
@@ -33,6 +36,9 @@ const Header = (props) => {
"/myportal/error",
"/accessibility",
"/details-about-cookies",
"/auth/verify-request",
"/auth/signin",
"/auth/error",
];
const hasContactLink = [
"/dns/application-process",
@@ -214,7 +220,8 @@ const Header = (props) => {
<a
onClick={() => {
destroyCookie({}, "pinsUser"),
window.localStorage.clear();
window.localStorage.clear(),
signOut({ callbackUrl: "/logout" });
}}
className="govuk-header__link govuk-!-margin-right-3"
>
+24 -12
View File
@@ -120,7 +120,7 @@ let Login = (props) => {
GG_REDIRECT_URI,
} = props;
const { session, status } = useSession();
const { data: session } = useSession();
const router = useRouter();
const { locale } = router;
@@ -226,18 +226,30 @@ let Login = (props) => {
{t("home:login-card-title")}
</h3>{" "}
<div className="govuk-form-group govuk-!-margin-top-4">
{" "}
Not Signed in
<div className="govuk-body">
{session && "Signed in as " + session.user?.email}
</div>
<br />
<button
className="govuk-button"
type="button"
onClick={() => signIn()}
>
Magic Link Sign in
</button>
{!session && (
<button
className="govuk-button withChevron govuk-button-cta"
type="button"
onClick={() => signIn("email")}
>
Sign in with email address
</button>
)}
{session && (
<button
className="govuk-button"
type="button"
onClick={() => signOut()}
>
Magic Link Sign Out
</button>
)}
</div>
<form onSubmit={handleSubmit(onHandleSubmit)}>
{/* <form onSubmit={handleSubmit(onHandleSubmit)}>
{validLoginID == false && (
<div className="govuk-error-message govuk-form-group--error">
Incorrect username or password
@@ -387,7 +399,7 @@ let Login = (props) => {
{t("home:login-contact-email")}
</a>
</p>
</div>
</div> */}
</div>
{/* <LoadingOverlay
+2 -1
View File
@@ -12,7 +12,7 @@ import Dns from "./homepage/dns";
const MainHome = (props) => {
let { t } = useTranslation();
const { showLogin, GG_REDIRECT_URI, GG_CLIENT_ID } = props;
const { showLogin, GG_REDIRECT_URI, GG_CLIENT_ID, session } = props;
const router = useRouter();
const { locale } = router;
@@ -33,6 +33,7 @@ const MainHome = (props) => {
<Login
GG_CLIENT_ID={GG_CLIENT_ID}
GG_REDIRECT_URI={GG_REDIRECT_URI}
session={session}
/>
)}
{/* <Inspectorate /> */}
+4 -1
View File
@@ -19,6 +19,8 @@ import { useState } from "react";
import TimeOut from "../components/timeout";
import UploadFile from "./myportal/uploadFile";
import { useSession, signIn, signOut } from "next-auth/react";
const MyPortal = (props) => {
const { showFileUpload } = props;
let { t } = useTranslation();
@@ -57,7 +59,8 @@ const MyPortal = (props) => {
console.log("////////////", "\n", "logout", "\n", "//////////");
destroyCookie({}, "pinsUser"),
window.localStorage.clear(),
router.replace(props.ggLogout);
//router.replace(props.ggLogout);
signOut({ callbackUrl: "/logout" });
};
return (
+2 -2
View File
@@ -27,7 +27,7 @@ export default function YourAccount() {
</div>
</div>
<div className="card-body">
{/* <div className="card-body">
<h3 className="heading-small card-heading">
{t("myportal:changepassword-card-title")}
</h3>
@@ -43,7 +43,7 @@ export default function YourAccount() {
</a>
</Link>
</div>
</div>
</div> */}
</div>
</>
);