migrate auth db to sql server
This commit is contained in:
+16
-14
@@ -18,6 +18,7 @@ import { reduxForm, formValueSelector } from "redux-form";
|
||||
|
||||
import RegisterForm from "../../components/account/registerform";
|
||||
import { dehashString, hashAPIPath } from "../../actions";
|
||||
import { getSession, useSession, signIn, signOut } from "next-auth/react";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, formData, loggedInUserEmail } = props;
|
||||
@@ -156,22 +157,23 @@ const Home = (props) => {
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) =>
|
||||
async ({ query, req, res }) => {
|
||||
let hasRegistrationEmail = typeof query.id != "undefined";
|
||||
let loginEmailStr = "";
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
|
||||
if (hasRegistrationEmail == true) {
|
||||
loginEmailStr = dehashString(query.id);
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
console.log(loginEmailStr);
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
loggedInUserEmail: loginEmailStr,
|
||||
},
|
||||
};
|
||||
}
|
||||
console.log(
|
||||
"auth sess for register :",
|
||||
thisSession,
|
||||
thisSession.user.email
|
||||
);
|
||||
|
||||
return {
|
||||
props: {
|
||||
loggedInUserEmail: thisSession.user.email,
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
|
||||
@@ -125,6 +125,12 @@ export default NextAuth({
|
||||
//signOut: "/auth/signout",
|
||||
error: "/auth/error", // Error code passed in query string as ?error=
|
||||
verifyRequest: "/auth/verify-request", // (used for check email message)
|
||||
// newUser: "/auth/new-user", // New users will be directed here on first sign in (leave the property out if not of interest)
|
||||
newUser: "/account/register", // New users will be directed here on first sign in (leave the property out if not of interest)
|
||||
},
|
||||
callbacks: {
|
||||
session: async (session, user) => {
|
||||
console.log(user);
|
||||
return Promise.resolve(session);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ function Error({ statusCode }, props) {
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
{t("case:page-title")} - {t("common:service-name")}
|
||||
{t("common:error-page-title")} - {t("common:service-name")}
|
||||
</title>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
|
||||
+13
-2
@@ -44,7 +44,13 @@ const Home = (props) => {
|
||||
expDate.setDate(now.getDate() + 1);
|
||||
|
||||
//console.log("hashed email str", loginEmailStr);
|
||||
hasLoginCode != false
|
||||
|
||||
//const { data: session } = useSession();
|
||||
|
||||
//console.log("has session:", session);
|
||||
//console.log("has LoginCode", hasLoginCode);
|
||||
|
||||
hasLoginCode == false
|
||||
? console.log("no session")
|
||||
: _.has(loggedInUserId, "value")
|
||||
? _.isEmpty(loggedInUserId.value)
|
||||
@@ -163,6 +169,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
console.log(ctx);
|
||||
|
||||
var relayToken = await getToken();
|
||||
relayToken = relayToken.access_token;
|
||||
|
||||
@@ -171,7 +179,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||
const showMapCheck = process.env.SHOWMAPS || false;
|
||||
|
||||
const hasLoginCode = thisSession != null;
|
||||
let hasLoginCode = thisSession != null;
|
||||
|
||||
console.log("server side has session:", thisSession != null);
|
||||
|
||||
// let providerConfig = await getProviderConfig();
|
||||
let ggLocale =
|
||||
@@ -227,6 +237,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
hasSession: hasLoginCode,
|
||||
loggedInUserId: portalUserObj,
|
||||
loggedInUserEmail: loginEmailStr,
|
||||
hasLoginCode: hasLoginCode,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
@@ -24,7 +26,7 @@ import { getGovGatewayConfig } from "../../store/govgateway/action";
|
||||
import { getProviderConfig } from "../../actions/govgateway";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages, formData } = props;
|
||||
const { footerLinks, pages, formData, loggedInUserIdent } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
@@ -118,6 +120,7 @@ const Home = (props) => {
|
||||
appealType={props.setAppealType}
|
||||
loggedInUser={props.accountDetails.loggedinUserId}
|
||||
whichForm={props.form}
|
||||
loggedInUserIdent={loggedInUserIdent}
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
@@ -135,7 +138,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const { cookies } = req;
|
||||
|
||||
console.log("/newappeal - cookies ", cookies);
|
||||
let thisSession = await getSession(ctx);
|
||||
console.log("nextAuth Session:", thisSession);
|
||||
|
||||
let loggedInUserIdent = thisSession.user.id;
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
|
||||
console.log("has loggedInUser", loggedInUser);
|
||||
@@ -157,6 +163,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setLPA(lpaData));
|
||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
|
||||
return {
|
||||
props: { loggedInUserIdent: loggedInUserIdent },
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user