-
Notifications
You must be signed in to change notification settings - Fork 85
/
waterlock-local-auth.js
61 lines (52 loc) · 1.34 KB
/
waterlock-local-auth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
var path = require('path');
exports.authType = 'local';
/**
* [installPath description]
* @type {[type]}
*/
exports.installPath = path.normalize(__dirname+'/../../../');
/**
* Conditionally export mail trasport data if
* user has opted for password tokens i.e. password
* resets
*/
var configPath = path.normalize(__dirname+'/../../../config/waterlock.js');
var wlconfig = require(configPath).waterlock;
var method = {};
if(typeof wlconfig.authMethod[0] === 'object'){
for(var i = 0; i < wlconfig.authMethod.length; i++){
if(wlconfig.authMethod[i].name === 'waterlock-local-auth'){
method = wlconfig.authMethod[i];
}
}
}else{
method = wlconfig.authMethod;
}
/**
* the entire config
*/
exports.config = wlconfig;
/**
* the config for this method
*/
exports.authConfig = method;
if(typeof method === 'object' &&
typeof method.passwordReset !== 'undefined' &&
method.passwordReset.tokens){
var nodemailer = require('nodemailer');
var sgTransport = require('nodemailer-sendgrid-transport');
var mail = method.passwordReset.sgOptions;
var transport = nodemailer.createTransport(sgTransport(mail));
exports.transport = transport;
}
/**
* [actions description]
* @type {[type]}
*/
exports.actions = require('./controllers');
/**
* [model description]
* @type {[type]}
*/
exports.model = require('./models');