perfood / couch-auth

Powerful authentication for APIs and apps using CouchDB (or Cloudant) with Node >= 14
MIT License
66 stars 19 forks source link

Confirm email template not found #38

Closed Ngomana closed 2 years ago

Ngomana commented 2 years ago

I was going through the tutorial on screen on getting started, I'm able to register and login but I'm unable to receive confirmEmail notification, I'm using a namecheap email to send out the emails.

I've tried adding a template for confirm email confirmEmail.njk

import express from "express";
import bodyParser from "body-parser";
import logger from "morgan";
import { SuperLogin } from "@perfood/couch-auth";

const app = express();
app.set("port", process.env.PORT || 3000);
app.use(logger("dev"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

// Initialize SuperLogin
const superlogin = new SuperLogin({
  dbServer: {
    protocol: "http://",
    host: "localhost:5984",
    user: "admin",
    password: "passowrd",
    userDB: "sl-users",
    couchAuthDB: "_users",
  },
  mailer: {
    fromEmail: "email@namecheap.com",
    options: {
      service: "email",
      auth: {
        user: "email@namecheap.com",
        pass: "password",
      },
    },
  },
  userDBs: {
    defaultDBs: {
      private: ["supertest"],
    },
  },
});

// Mount SuperLogin's routes to our app
app.use("/auth", superlogin.router);
app.listen(app.get("port"));

But I get this error when I register a new user: Screenshot 2022-04-21 at 00 25 37

fynnlyte commented 2 years ago

Do you use node 16 or node 14? I've also seen problems with node 14 in the pipeline with the beta

fynnlyte commented 2 years ago

Yeah try using node 16 until I've figured out what the problem here. v0.17.0-beta.2 work well with node 16, but rendering the templates doesn't work on node 14. I guess I'm doing something wrong with the paths here.

fynnlyte commented 2 years ago

Ah, String.replaceAll() isn't available in node 14, that's why.

Ngomana commented 2 years ago

Do you use node 16 or node 14? I've also seen problems with node 14 in the pipeline with the beta

I've upgraded to version 16, but still getting the same error. Am I supposed to create my own template?

Screenshot 2022-04-23 at 05 48 39

fynnlyte commented 2 years ago

I didn't specify the correct path in the default template. Should be fixed now.

npm i @perfood/couch-auth@0.17.0-beta.3

Usually, you'll want to define your own templates by providing the folder via the config. See https://github.com/perfood/couch-auth#email-templates