2017-11-16 16:45:01 +01:00
|
|
|
'use strict';
|
|
|
|
|
2020-02-21 23:20:06 +01:00
|
|
|
const gravatarUrl = require('gravatar-url');
|
2020-01-02 19:23:52 +01:00
|
|
|
const Joi = require('@hapi/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 =
|
2020-02-21 23:20:06 +01:00
|
|
|
imageUrl || gravatarUrl(email, { size: '42', default: 'retro' });
|
2017-11-16 16:45:01 +01:00
|
|
|
}
|
|
|
|
};
|