@heymarco/next-auth
Version:
A complete authentication solution for web applications.
181 lines (180 loc) • 8.97 kB
JavaScript
// react:
import {
// react:
default as React, } from 'react';
// reusable-ui core:
import {
// a border (stroke) management system:
borderRadiusValues,
// a spacer (gap) management system
spacerValues, } from '@reusable-ui/core'; // a set of reusable-ui packages which are responsible for building any component
// auth-js:
// import GoogleProvider from '@auth/core/providers/google' // doesn't work
// import FacebookProvider from '@auth/core/providers/facebook' // doesn't work
// import InstagramProvider from '@auth/core/providers/instagram' // doesn't work
// import TwitterProvider from '@auth/core/providers/twitter' // doesn't work
// next-auth:
import GoogleProvider from 'next-auth/providers/google'; // works
import FacebookProvider from 'next-auth/providers/facebook'; // works
import InstagramProvider from 'next-auth/providers/instagram'; // works
import TwitterProvider from 'next-auth/providers/twitter'; // works
// templates:
import * as styles from './templates/styles.js';
import {
// react components:
Business, } from './templates/Business.js';
import {
// react components:
EmailConfirmation, } from './templates/EmailConfirmation.js';
import {
// react components:
User, } from './templates/User.js';
import {
// react components:
PasswordReset, } from './templates/PasswordReset.js';
import { defaultAuthConfigShared, } from './auth.config.shared.js';
export const defaultAuthConfigServer = {
business: defaultAuthConfigShared.business,
signUp: defaultAuthConfigShared.signUp,
signIn: {
...defaultAuthConfigShared.signIn,
requireVerifiedEmail: true,
failureMaxAttempts: 5 /* times */,
failureLockDuration: 0.25 /* hours */,
},
reset: {
...defaultAuthConfigShared.reset,
throttle: 0.08 /* hours */,
maxAge: 24 /* hours */,
},
session: {
maxAge: 24 /* hours */,
updateAge: 6 /* hours */,
},
oAuthProviders: [
GoogleProvider({
clientId: process.env.GOOGLE_ID ?? '',
clientSecret: process.env.GOOGLE_SECRET ?? '',
allowDangerousEmailAccountLinking: true,
}),
FacebookProvider({
clientId: process.env.FACEBOOK_ID ?? '',
clientSecret: process.env.FACEBOOK_SECRET ?? '',
allowDangerousEmailAccountLinking: true,
}),
InstagramProvider({
clientId: process.env.INSTAGRAM_ID ?? '',
clientSecret: process.env.INSTAGRAM_SECRET ?? '',
allowDangerousEmailAccountLinking: true,
}),
TwitterProvider({
clientId: process.env.TWITTER_ID ?? '',
clientSecret: process.env.TWITTER_SECRET ?? '',
// @ts-ignore
version: '2.0',
allowDangerousEmailAccountLinking: true,
}),
],
emails: {
signUp: {
host: process.env.EMAIL_SIGNUP_HOST ?? '',
port: Number.parseInt(process.env.EMAIL_SIGNUP_PORT ?? '465'),
secure: (process.env.EMAIL_SIGNUP_SECURE === 'true'),
username: process.env.EMAIL_SIGNUP_USERNAME ?? '',
password: process.env.EMAIL_SIGNUP_PASSWORD ?? '',
from: process.env.EMAIL_SIGNUP_FROM ?? '',
subject: React.createElement(React.Fragment, null,
"Your Account Registration at ",
React.createElement(Business.Name, null)),
message: React.createElement("article", { style: styles.article },
React.createElement("div", { style: styles.sectionDummy }),
React.createElement("section", {
// styles:
style: {
// layouts:
...styles.sectionBase,
// backgrounds & foregrounds:
...styles.theme('primary'),
// borders:
border: styles.borderStroke('primary'),
borderRadius: `${borderRadiusValues.xxl}`,
// spacings:
margin: `${spacerValues.md}`,
padding: `calc(${spacerValues.md} * 1.5)`,
} },
React.createElement("h1", { style: styles.heading1 }, "Your Account Is Almost Ready!"),
React.createElement("p", { style: styles.paragraph },
"Dear ",
React.createElement(User.Name, null),
","),
React.createElement("p", { style: styles.paragraph },
"You've successfully signed up for an account at ",
React.createElement(Business.Name, null),
"."),
React.createElement("p", { style: styles.paragraphLast },
"Your account has been created but ",
React.createElement("strong", null, "not yet activated"),
".",
React.createElement("br", null),
"Please follow the activation instruction below.")),
React.createElement("section", { style: styles.section },
React.createElement("h2", { style: styles.heading2 }, "Account Activation Instruction"),
React.createElement("p", { style: styles.paragraphLast },
"In order to sign in to our website, you need to confirm your email address by clicking on the link below:",
React.createElement("br", null),
React.createElement(EmailConfirmation.Link, null))),
React.createElement("section", { style: styles.sectionLast },
React.createElement("h2", { style: styles.heading2 }, "Not You?"),
React.createElement("p", { style: styles.paragraphLast }, "If you did not signed up on our website then please ignore this email."))),
},
reset: {
host: process.env.EMAIL_RESET_HOST ?? '',
port: Number.parseInt(process.env.EMAIL_RESET_PORT ?? '465'),
secure: (process.env.EMAIL_RESET_SECURE === 'true'),
username: process.env.EMAIL_RESET_USERNAME ?? '',
password: process.env.EMAIL_RESET_PASSWORD ?? '',
from: process.env.EMAIL_RESET_FROM ?? '',
subject: React.createElement(React.Fragment, null,
"Password Reset Request at ",
React.createElement(Business.Name, null)),
message: React.createElement("article", { style: styles.article },
React.createElement("div", { style: styles.sectionDummy }),
React.createElement("section", {
// styles:
style: {
// layouts:
...styles.sectionBase,
// backgrounds & foregrounds:
...styles.theme('primary'),
// borders:
border: styles.borderStroke('primary'),
borderRadius: `${borderRadiusValues.xxl}`,
// spacings:
margin: `${spacerValues.md}`,
padding: `calc(${spacerValues.md} * 1.5)`,
} },
React.createElement("h1", { style: styles.heading1 }, "Forgot Your Password?"),
React.createElement("p", { style: styles.paragraph },
"Dear ",
React.createElement(User.Name, null),
","),
React.createElement("p", { style: styles.paragraphLast },
"We received a request to ",
React.createElement("strong", null, "reset your password"),
" at ",
React.createElement(Business.Name, null),
".",
React.createElement("br", null),
"Please follow the password reset instruction below.")),
React.createElement("section", { style: styles.section },
React.createElement("h2", { style: styles.heading2 }, "Password Reset Instruction"),
React.createElement("p", { style: styles.paragraphLast },
"To reset your password, click on the link below:",
React.createElement("br", null),
React.createElement(PasswordReset.Link, null))),
React.createElement("section", { style: styles.sectionLast },
React.createElement("h2", { style: styles.heading2 }, "Not You?"),
React.createElement("p", { style: styles.paragraphLast }, "If you did not make this request then please ignore this email."))),
},
},
};