mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
31 lines
808 B
JavaScript
31 lines
808 B
JavaScript
'use strict';
|
|
|
|
const gravatarUrl = require('gravatar-url');
|
|
const Joi = require('@hapi/joi');
|
|
|
|
module.exports = class User {
|
|
constructor({
|
|
name,
|
|
email,
|
|
username,
|
|
systemId,
|
|
imageUrl,
|
|
permissions,
|
|
} = {}) {
|
|
if (!username && !email) {
|
|
throw new TypeError('Username or Email us reuqired');
|
|
}
|
|
Joi.assert(email, Joi.string().email(), 'Email');
|
|
Joi.assert(username, Joi.string(), 'Username');
|
|
Joi.assert(name, Joi.string(), 'Name');
|
|
|
|
this.name = name;
|
|
this.username = username;
|
|
this.email = email;
|
|
this.systemId = systemId;
|
|
this.permissions = permissions;
|
|
this.imageUrl =
|
|
imageUrl || gravatarUrl(email, { size: '42', default: 'retro' });
|
|
}
|
|
};
|