1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/server/api/models/User.js

120 lines
2.9 KiB
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
/**
* User.js
*
* @description :: A model definition represents a database table/collection.
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
module.exports = {
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
email: {
type: 'string',
isEmail: true,
required: true,
2019-08-31 04:07:25 +05:00
},
password: {
type: 'string',
},
isAdmin: {
type: 'boolean',
defaultsTo: false,
columnName: 'is_admin',
2019-08-31 04:07:25 +05:00
},
name: {
type: 'string',
required: true,
2019-08-31 04:07:25 +05:00
},
2020-04-03 00:35:25 +05:00
username: {
type: 'string',
isNotEmptyString: true,
minLength: 3,
maxLength: 16,
2021-04-13 18:59:02 +05:00
regex: /^[a-zA-Z0-9]+((_|\.)?[a-zA-Z0-9])*$/,
2020-04-03 00:35:25 +05:00
allowNull: true,
},
avatar: {
type: 'json',
2019-08-31 04:07:25 +05:00
},
phone: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
},
organization: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
},
language: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',
defaultsTo: false,
columnName: 'subscribe_to_own_cards',
},
2019-08-31 04:07:25 +05:00
deletedAt: {
type: 'ref',
columnName: 'deleted_at',
2019-08-31 04:07:25 +05:00
},
passwordChangedAt: {
type: 'ref',
columnName: 'password_changed_at',
},
2023-09-04 10:06:59 -05:00
locked: {
type: 'boolean',
columnName: 'locked',
},
2019-08-31 04:07:25 +05:00
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
managerProjects: {
2019-08-31 04:07:25 +05:00
collection: 'Project',
via: 'userId',
through: 'ProjectManager',
},
membershipBoards: {
collection: 'Board',
via: 'userId',
through: 'BoardMembership',
2019-08-31 04:07:25 +05:00
},
subscriptionCards: {
collection: 'Card',
via: 'userId',
through: 'CardSubscription',
2019-08-31 04:07:25 +05:00
},
membershipCards: {
collection: 'Card',
via: 'userId',
through: 'CardMembership',
},
2023-09-04 10:06:59 -05:00
identityProviders: {
collection: 'IdentityProviderUser',
via: 'userId',
},
2019-08-31 04:07:25 +05:00
},
tableName: 'user_account',
customToJSON() {
2019-08-31 04:07:25 +05:00
return {
..._.omit(this, ['password', 'avatar', 'passwordChangedAt']),
2020-04-21 05:04:34 +05:00
avatarUrl:
this.avatar &&
`${sails.config.custom.userAvatarsUrl}/${this.avatar.dirname}/square-100.${this.avatar.extension}`,
2019-08-31 04:07:25 +05:00
};
},
2019-08-31 04:07:25 +05:00
};