loopback-register-user-mixin

REGISTER USER MIXIN =============

Usage no npm install needed!

<script type="module">
  import loopbackRegisterUserMixin from 'https://cdn.skypack.dev/loopback-register-user-mixin';
</script>

README

REGISTER USER MIXIN

This module is for the loopback framework. It handles user registration.

INSTALL

  npm i loopback-register-user-mixin --S

SERVER CONFIG

Add the mixins property to your server/model-config.json:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "../node_modules/loopback-register-user-mixin/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-register-user-mixin",
      "../common/mixins"
    ]
  }
}
  "RequestBody": {
    "public": false
  }

MODEL CONFIG

  {
    "name": "User",
    "properties": {
      "name": {
        "type": "string",
      }
    },
    "mixins": {
      "RegisterUser": true
    }
  }

CONFIG EMAIL

  Member.beforeRemote('register', (ctx, _, next) => {
    ctx.emailConfig = {
      redirect: `${URL}/confirm`,
      from: 'example@example.com',
      subject: 'Thanks for Registering | Example app',
      templatePath: path.resolve(__dirname, './emails/verify-email.ejs'),
      templateData: {
        signature: 'Elon',
        buttonText: 'Activate account',
        lines: [
          'Thank you',
          'Thanks for registering. Please follow the link below to complete your registration.',
        ],
      },
    };
    next();
  });