2017-11-16 16:45:01 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const gravatar = require('gravatar');
|
2018-01-17 09:27:47 +01:00
|
|
|
const Joi = require('joi');
|
2017-11-16 16:45:01 +01:00
|
|
|
|
|
|
|
module.exports = class User {
|
2018-12-19 10:36:56 +01:00
|
|
|
constructor({ name, email, permissions, imageUrl } = {}) {
|
2018-01-17 09:27:47 +01:00
|
|
|
Joi.assert(
|
|
|
|
email,
|
|
|
|
Joi.string()
|
|
|
|
.email()
|
|
|
|
.required(),
|
|
|
|
'Email'
|
|
|
|
);
|
2017-11-16 16:45:01 +01:00
|
|
|
this.email = email;
|
|
|
|
this.name = name;
|
2018-12-19 10:36:56 +01:00
|
|
|
this.permissions = permissions;
|
2017-11-16 16:45:01 +01:00
|
|
|
this.imageUrl =
|
|
|
|
imageUrl || gravatar.url(email, { s: '42', d: 'retro' });
|
|
|
|
}
|
|
|
|
};
|