{
- window.localStorage.clear();
+ destroyCookie(null, "pinsUser"),
+ window.localStorage.clear();
}}
className="govuk-header__link govuk-!-margin-right-3"
>
diff --git a/components/homepage/login.js b/components/homepage/login.js
index ac52a10f..9d0526dc 100644
--- a/components/homepage/login.js
+++ b/components/homepage/login.js
@@ -1,5 +1,5 @@
import Link from "next/link";
-import { useState } from "react";
+import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { connect } from "react-redux";
@@ -7,6 +7,7 @@ import { Field, reduxForm } from "redux-form";
import LoadingOverlay from "react-loading-overlay";
import { getLogin } from "../../actions";
import { setLoggedInUserId } from "../../store/accountDetails/action";
+import { parseCookies, setCookie, destroyCookie } from "nookies";
const required = (errorMsg) => (value) =>
value || typeof value === "number" ? undefined : errorMsg;
@@ -128,17 +129,30 @@ let Login = (props) => {
data.value.length != 0
? (setValidLoginID(true),
setLoggedInUserId(data.value[0].contactid),
+ setCookie(null, "pinsUser", data.value[0].contactid, {
+ path: "/",
+ }),
spinnerState(),
router.replace({
pathname:
router.locale == "cy" ? "/fymhorth" : "/myportal",
- query: { q: data.value[0].contactid },
shallow: true,
}))
: (setShowSpinnerState(false), setValidLoginID(false));
});
};
+ const cookies = parseCookies();
+
+ useEffect(() => {
+ cookies.pinsUser != null || typeof cookies.pinsUser != "undefined"
+ ? (spinnerState(),
+ router.replace("/myportal", null, {
+ shallow: true,
+ }))
+ : "";
+ }, []);
+
return (