Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,8 @@ module.exports = function( grunt ) {
unit: {
options: {
require: [ 'chai' ],
reporter: 'spec'
reporter: 'spec',
timeout: 5000
},
src: [ 'tests/unit/*.js' ].concat( getModulePaths( 'tests', 'unit', '*.js' ) )
},
Expand Down
2 changes: 1 addition & 1 deletion lib/config/index.js
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
var path = require( 'path' );

module.exports = require( path.resolve( [ __dirname, '..', 'config' ].join( path.sep ) ) + path.sep );
module.exports = require( path.resolve( [ __dirname, '..', '..', 'config' ].join( path.sep ) ) + path.sep );
118 changes: 118 additions & 0 deletions modules/auth/models/orm/AccountModel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
module.exports = function(sequelize, DataTypes) {
return sequelize.define("Account", {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: DataTypes.STRING,
validate: {
len: [ 2, 50 ]
}
},
subdomain: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
isAlphanumeric: true,
len: [ 3, 16 ]
}
},
active: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
logo : {
type: DataTypes.STRING,
allowNull: true
},
themeColor : {
type: DataTypes.STRING,
allowNull: true
},
email : {
type: DataTypes.STRING,
allowNull: true,
unique: true,
validate: {
isEmail: true
}
},
emailFwd : {
type: DataTypes.STRING,
allowNull: true
},
info: {
type: DataTypes.TEXT,
allowNull: true
},
benefits: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
dependents: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
documents: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
emergency: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
boarding: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
timeoff: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
training: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
date_format: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: "yyyy-mm-dd"
},
number_format: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: "123'456.78"
},
currency: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: "USD"
},
quickstart: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
}
},
{
instanceMethods: {
toJSON: function () {
var values = this.values;
delete values.createdAt;
delete values.updatedAt;
return values;
}
}
});
};
86 changes: 86 additions & 0 deletions modules/auth/models/orm/UserModel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
module.exports = function(sequelize, DataTypes) {
return sequelize.define("User", {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
username: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
isEmail: true
}
},
password: {
type: DataTypes.STRING,
allowNull: false
},
firstname: {
type: DataTypes.STRING,
allowNull: true
// validate: {
// isAlphanumeric: true
// }
},
lastname: {
type: DataTypes.STRING,
allowNull: true
// validate: {
// isAlphanumeric: true
// }
},
phone : {
type:DataTypes.STRING,
allowNull: true
},
confirmed : {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
active : {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true
},
hasAdminRight : {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
accessedAt : {
type: DataTypes.DATE,
allowNull: true
},
AccountId : {
type: DataTypes.INTEGER
},
EmailTemplateId : {
type: DataTypes.INTEGER
}

},
{
paranoid: true,
getterMethods: {
fullName: function(){
return [ this.getDataValue('firstname'), this.getDataValue('lastname')].join(' ');
}
},
instanceMethods: {
toJSON: function () {
var values = this.values;
values.fullName = this.fullName;
delete values.password;
return values;
}
}
});
};
34 changes: 34 additions & 0 deletions modules/clever-email/config/default.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
{
"clever-email": {
"cc": true,
"bcc": true,
"text": false,

"systems": {
"Mandrill": {
"isActive": true,
"apiKey": "anyaWGoRNAFaQQW79MwqAA",
"async": false
},
"SendGrid": {
"isActive": false,
"apiUser" : "",
"apiKey" : ""
},
"MailGun": {
"isActive": false,
"domain" : "mytestdomain.com",
"apiKey" : "key-97zzcleh7dgz0kp4jfy1qp0fn38lml73"
}
},

"default": {
"noReply": "true",
"from": "no-reply@app.bolthr.com",
"fromName": "BoltHR",
"subject": "BoltHR: Autogenerated Notification",
"tplName": "default",
"logo": "http://app.bolthr.com/images/logo.png"
}
}
}
91 changes: 91 additions & 0 deletions modules/clever-email/controllers/EmailController.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
module.exports = function ( EmailService ) {

return (require( 'classes' ).Controller).extend(
{
service: null
},
/* @Prototype */
{

listAction: function () {
var userId = this.req.user.id;

EmailService
.listEmails( userId )
.then( this.proxy( 'handleServiceMessage' ) )
.fail( this.proxy( 'handleException' ) );
},

getAction: function () {
var userId = this.req.user.id
, emailId = this.req.params.id;

EmailService
.getEmailByIds( userId, emailId )
.then( this.proxy( 'handleServiceMessage' ) )
.fail( this.proxy( 'handleException' ) );
},

postAction: function () {
var userId = this.req.user.id
, accId = this.req.user.account.id
, accLogo = this.req.user.account.logo
, accName = this.req.user.account.name
, userFirstName = this.req.user.firstname
, userLastName = this.req.user.lastname
, data = this.req.body;

data = data.map( function ( x ) {
x.userId = userId;
x.accId = accId;
x.userFirstName = userFirstName;
x.userLastName = userLastName;
x.accLogo = accLogo;
x.accName = accName;
return x;
} );

EmailService
.handleEmailCreation( data )
.then( this.proxy( 'handleServiceMessage' ) )
.fail( this.proxy( 'handleException' ) );
},

putAction: function () {
this.send( 'invalid', 403 );
},

deleteAction: function () {
var userId = this.req.user.id
, emailId = this.req.params.id;

EmailService
.deleteEmail( userId, emailId )
.then( this.proxy( 'handleServiceMessage' ) )
.fail( this.proxy( 'handleException' ) );
},

sendAction: function () {
var userId = this.req.user.id
, emailId = this.req.params.id
, type = this.req.body.type;

EmailService
.handleEmailSending( userId, emailId, type )
.then( this.proxy( 'handleServiceMessage' ) )
.fail( this.proxy( 'handleException' ) );

},

handleServiceMessage: function ( obj ) {

if ( obj.statuscode ) {
this.send( obj.message, obj.statuscode );
return;
}

this.send( obj, 200 );
}

} );
};
17 changes: 17 additions & 0 deletions modules/clever-email/lib/mailer.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
module.exports = function ( config ) {

var mandrill = require( './mandrill' )
, sendgrid = require( './sendgrid' )
, mailgun = require( './mailgun' )
, confs = config.systems;

var mailer = confs.Mandrill.isActive
? mandrill
: confs.SendGrid.isActive
? sendgrid
: confs.MailGun.isActive
? mailgun
: mandrill;

return mailer( config );
};
Loading