diff --git a/.env.local b/.env.local index 57c12778..af89d049 100644 --- a/.env.local +++ b/.env.local @@ -19,11 +19,11 @@ RELAYPATH = "dev-pedw-hc" //Test Oauth ESNR -CLIENT_ID = d40b9373-96c2-4b04-8bd8-c2a2fe6444c1 -CLIENT_SECRET = IXI8Q~D5oqsC-nrtayHHc~tUAfjQFzNiKVQ~fc2S -RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ -RELAYURI = "test-pedw-ns.servicebus.windows.net" -RELAYPATH = "test-pedw-hc" +//CLIENT_ID = d40b9373-96c2-4b04-8bd8-c2a2fe6444c1 +//CLIENT_SECRET = IXI8Q~D5oqsC-nrtayHHc~tUAfjQFzNiKVQ~fc2S +//RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ +//RELAYURI = "test-pedw-ns.servicebus.windows.net" +//RELAYPATH = "test-pedw-hc" //Preprod Oauth WGO @@ -44,7 +44,7 @@ RELAYPATH = "test-pedw-hc" GOOGLE_TAG_MANAGER = GTM-T78CBC3 -SHOWLOGIN = "false" +SHOWLOGIN = "true" SHOWREPRESENTATIONS = false SHOWFILEUPLOAD = "false" SHOWMAPS = "true" diff --git a/components/main.js b/components/main.js index 884d949e..11af2de7 100644 --- a/components/main.js +++ b/components/main.js @@ -25,14 +25,21 @@ const MainHome = (props) => {
- {showLogin != "true" && } - + {showLogin != "true" && ( + <> + + + + )} {showLogin == "true" && ( - + <> + + + )}{" "} diff --git a/package.json b/package.json index 14e680bd..96550984 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "nextjs-basic-auth-middleware": "^0.2.1", "nodemailer": "^6.7.8", "nookies": "^2.5.2", + "notifications-node-client": "^5.1.1", "ospoint": "^0.2.1", "path": "^0.12.7", "react": "17.0.2", diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index 068c3b30..baf1ec65 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -3,82 +3,10 @@ import EmailProvider from "next-auth/providers/email"; import { PrismaAdapter } from "@next-auth/prisma-adapter"; import { PrismaClient } from "@prisma/client"; import nodemailer from "nodemailer"; +import { consoleLogger } from "../../../actions"; const prisma = new PrismaClient(); -// async function sendVerificationRequest({ -// identifier: email, -// url, -// provider: { server, from }, -// }) { -// const { host } = new URL(url); -// const transport = nodemailer.createTransport(server); -// await transport.sendMail({ -// to: email, -// from, -// subject: `Sign in to ${host}`, -// text: text({ url, host }), -// html: html({ url, host, email }), -// }); -// } -// Email HTML body -function html({ url, host, email }) { - // Insert invisible space into domains and email address to prevent both the - // email address and the domain from being turned into a hyperlink by email - // clients like Outlook and Apple mail, as this is confusing because it seems - // like they are supposed to click on their email address to sign in. - const escapedEmail = `${email.replace(/\./g, "​.")}`; - const escapedHost = `${host.replace(/\./g, "​.")}`; - - // Some simple styling options - const backgroundColor = "#ffffff"; - const textColor = "#444444"; - const mainBackgroundColor = "#ffffff"; - const buttonBackgroundColor = "#aa1111"; - const buttonBorderColor = "#aa1111"; - const buttonTextColor = "#ffffff"; - const headerBackgroundColor = "#000000"; - - return ` - - - - - - - - - - - - - -
-
- Sign in as ${escapedEmail} -
- - - - -
Sign in
-
- If you did not request this email you can safely ignore it. -
- - `; -} - -// Email Text body (fallback for email clients that don't render HTML, e.g. feature phones) -function text({ url, host }) { - return `Sign in to PEDW - Planning Casework\n${url}\n\n`; -} // For more information on each option (and a full list of options) go to // https://next-auth.js.org/configuration/options export default NextAuth({ @@ -101,14 +29,29 @@ export default NextAuth({ provider: { server, from }, }) { const { host } = new URL(url); - const transport = nodemailer.createTransport(server); - await transport.sendMail({ - to: email, - from, - subject: `Sign in to PEDW - Planning Casework`, - text: text({ url, host }), - html: html({ url, host, email }), - }); + const templateId = "b1b5704b-9bb8-4deb-a75c-d887ca902661"; + const emailAddress = email; + const personalisation = { + "emailAddress": email, + "signInLink": url, + "linkExpiry": 10 * 60, + }; + const reference = "PEDW-SIGNIN"; + + var NotifyClient = + require("notifications-node-client").NotifyClient; + + const notifyClient = new NotifyClient( + process.env.NOTIFY_API_KEY + ); + + await notifyClient + .sendEmail(templateId, emailAddress, { + personalisation: personalisation, + reference: reference, + // emailReplyToId: emailReplyToId, + }) + .catch((err) => consoleLogger(err)); }, }), ], diff --git a/pages/api/endpoint/getbasicpartsaveddetails_api.js b/pages/api/endpoint/getbasicpartsaveddetails_api.js index bbbaf2aa..2e7ac2ea 100644 --- a/pages/api/endpoint/getbasicpartsaveddetails_api.js +++ b/pages/api/endpoint/getbasicpartsaveddetails_api.js @@ -34,7 +34,7 @@ export default async function ApiProxy(req, res) { queryUrl = queryUrl; //+ getSelectQuery(appealTypeName); - //console.log("query: ", queryUrl, "<<<