From 6ed9da44690d5f68a5bb4e398c0a4ad4083ed6fa Mon Sep 17 00:00:00 2001 From: vantezzen Date: Thu, 2 Apr 2020 17:09:11 +0200 Subject: #16 Implement Password reset --- config/mail.js | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ config/persona.js | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 config/mail.js create mode 100644 config/persona.js (limited to 'config') diff --git a/config/mail.js b/config/mail.js new file mode 100644 index 0000000..6b18db2 --- /dev/null +++ b/config/mail.js @@ -0,0 +1,101 @@ +'use strict' + +const Env = use('Env') + +module.exports = { + /* + |-------------------------------------------------------------------------- + | Connection + |-------------------------------------------------------------------------- + | + | Connection to be used for sending emails. Each connection needs to + | define a driver too. + | + */ + connection: Env.get('MAIL_CONNECTION', 'smtp'), + + /* + |-------------------------------------------------------------------------- + | SMTP + |-------------------------------------------------------------------------- + | + | Here we define configuration for sending emails via SMTP. + | + */ + smtp: { + driver: 'smtp', + pool: true, + port: Env.get('SMTP_PORT', 2525), + host: Env.get('SMTP_HOST'), + secure: false, + auth: { + user: Env.get('MAIL_USERNAME'), + pass: Env.get('MAIL_PASSWORD') + }, + maxConnections: 5, + maxMessages: 100, + rateLimit: 10 + }, + + /* + |-------------------------------------------------------------------------- + | SparkPost + |-------------------------------------------------------------------------- + | + | Here we define configuration for spark post. Extra options can be defined + | inside the `extra` object. + | + | https://developer.sparkpost.com/api/transmissions.html#header-options-attributes + | + | extras: { + | campaign_id: 'sparkpost campaign id', + | options: { // sparkpost options } + | } + | + */ + sparkpost: { + driver: 'sparkpost', + apiKey: Env.get('SPARKPOST_API_KEY'), + extras: {} + }, + + /* + |-------------------------------------------------------------------------- + | Mailgun + |-------------------------------------------------------------------------- + | + | Here we define configuration for mailgun. Extra options can be defined + | inside the `extra` object. + | + | https://mailgun-documentation.readthedocs.io/en/latest/api-sending.html#sending + | + | extras: { + | 'o:tag': '', + | 'o:campaign': '',, + | . . . + | } + | + */ + mailgun: { + driver: 'mailgun', + domain: Env.get('MAILGUN_DOMAIN'), + region: Env.get('MAILGUN_API_REGION'), + apiKey: Env.get('MAILGUN_API_KEY'), + extras: {} + }, + + /* + |-------------------------------------------------------------------------- + | Ethereal + |-------------------------------------------------------------------------- + | + | Ethereal driver to quickly test emails in your browser. A disposable + | account is created automatically for you. + | + | https://ethereal.email + | + */ + ethereal: { + driver: 'ethereal' + } +} diff --git a/config/persona.js b/config/persona.js new file mode 100644 index 0000000..71fbc3f --- /dev/null +++ b/config/persona.js @@ -0,0 +1,98 @@ +'use strict' + +/* +|-------------------------------------------------------------------------- +| Persona +|-------------------------------------------------------------------------- +| +| The persona is a simple and opinionated service to register, login and +| manage user account +| +*/ + +module.exports = { + /* + |-------------------------------------------------------------------------- + | Uids + |-------------------------------------------------------------------------- + | + | An array of fields, that can be used to indetify a user uniquely. During + | login and reset password, these fields be checked against the user + | input + | + */ + uids: ['email'], + + /* + |-------------------------------------------------------------------------- + | Email field + |-------------------------------------------------------------------------- + | + | The name of the email field inside the database and the user payload. + | + */ + email: 'email', + + /* + |-------------------------------------------------------------------------- + | Password + |-------------------------------------------------------------------------- + | + | The password field to be used for verifying and storing user password + | + */ + password: 'password', + + /* + |-------------------------------------------------------------------------- + | New account state + |-------------------------------------------------------------------------- + | + | State of user when a new account is created + | + */ + newAccountState: 'pending', + + /* + |-------------------------------------------------------------------------- + | Verified account state + |-------------------------------------------------------------------------- + | + | State of user after they verify their email address + | + */ + verifiedAccountState: 'active', + + /* + |-------------------------------------------------------------------------- + | Model + |-------------------------------------------------------------------------- + | + | The model to be used for verifying and creating users + | + */ + model: 'App/Models/User', + + /* + |-------------------------------------------------------------------------- + | Date Format + |-------------------------------------------------------------------------- + | + | The date format for the tokens table. It is required to calculate the + | expiry of a token. + | + */ + dateFormat: 'YYYY-MM-DD HH:mm:ss', + + /* + |-------------------------------------------------------------------------- + | Validation messages + |-------------------------------------------------------------------------- + | + | An object of validation messages to be used when validation fails. + | + */ + validationMessages: () => { + return {} + } +} -- cgit v1.2.3-54-g00ecf