added api for testing email provider
This commit is contained in:
@@ -122,7 +122,7 @@ const parseUrl = (url) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const authOptions = (locale, req) => {
|
const authOptions = (locale, req, res) => {
|
||||||
//console.log(req.query.callbackUrl);
|
//console.log(req.query.callbackUrl);
|
||||||
// let newURL = parseUrl(
|
// let newURL = parseUrl(
|
||||||
// locale == "cy"
|
// locale == "cy"
|
||||||
@@ -132,6 +132,21 @@ const authOptions = (locale, req) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
providers: [
|
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({
|
EmailProvider({
|
||||||
maxAge: 10 * 60, // Magic links are valid for 10 min only
|
maxAge: 10 * 60, // Magic links are valid for 10 min only
|
||||||
async sendVerificationRequest({ identifier: email, url }) {
|
async sendVerificationRequest({ identifier: email, url }) {
|
||||||
@@ -143,7 +158,7 @@ const authOptions = (locale, req) => {
|
|||||||
const emailAddress = email;
|
const emailAddress = email;
|
||||||
console.log(
|
console.log(
|
||||||
"============================================================\n",
|
"============================================================\n",
|
||||||
"verificiation url: " + url + "\n",
|
"verification url: " + url + "\n",
|
||||||
"============================================================\n"
|
"============================================================\n"
|
||||||
);
|
);
|
||||||
let newURL =
|
let newURL =
|
||||||
@@ -236,5 +251,9 @@ export default (req, res) => {
|
|||||||
//console.log("----------", authOptions(req.cookies["pedw_locale"]));
|
//console.log("----------", authOptions(req.cookies["pedw_locale"]));
|
||||||
|
|
||||||
//console.log("----------",
|
//console.log("----------",
|
||||||
return NextAuth(req, res, authOptions(req.cookies["pedw_locale"], req));
|
return NextAuth(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
authOptions(req.cookies["pedw_locale"], req, res)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user