Merged PR 1046: added api for testing email provider

added api for testing email provider

Related work items: #9877
This commit is contained in:
Robert Bond
2023-12-15 13:41:41 +00:00
+22 -3
View File
@@ -122,7 +122,7 @@ const parseUrl = (url) => {
};
};
const authOptions = (locale, req) => {
const authOptions = (locale, req, res) => {
//console.log(req.query.callbackUrl);
// let newURL = parseUrl(
// locale == "cy"
@@ -132,6 +132,21 @@ const authOptions = (locale, req) => {
return {
providers: [
{
id: "emailAPI",
name: "emailAPI",
type: "email",
async sendVerificationRequest({ identifier: email, url }) {
const { host, port, protocol, token, searchParams } =
new URL(url);
console.log(
"============================================================\n",
"verification url API: " + url + "\n",
"============================================================\n"
);
return res.status(200).json({ url: url });
},
},
EmailProvider({
maxAge: 10 * 60, // Magic links are valid for 10 min only
async sendVerificationRequest({ identifier: email, url }) {
@@ -143,7 +158,7 @@ const authOptions = (locale, req) => {
const emailAddress = email;
console.log(
"============================================================\n",
"verificiation url: " + url + "\n",
"verification url: " + url + "\n",
"============================================================\n"
);
let newURL =
@@ -236,5 +251,9 @@ export default (req, res) => {
//console.log("----------", authOptions(req.cookies["pedw_locale"]));
//console.log("----------",
return NextAuth(req, res, authOptions(req.cookies["pedw_locale"], req));
return NextAuth(
req,
res,
authOptions(req.cookies["pedw_locale"], req, res)
);
};