Add suspendedAt column to teams
This commit is contained in:
13
server/migrations/20231123022323-add-suspended-at-teams.js
Normal file
13
server/migrations/20231123022323-add-suspended-at-teams.js
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn("teams", "suspendedAt", {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
});
|
||||
},
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeColumn("teams", "suspendedAt");
|
||||
},
|
||||
};
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Table,
|
||||
Unique,
|
||||
IsIn,
|
||||
IsDate,
|
||||
HasMany,
|
||||
Scopes,
|
||||
Is,
|
||||
@@ -151,8 +152,19 @@ class Team extends ParanoidModel {
|
||||
@Column(DataType.JSONB)
|
||||
preferences: TeamPreferences | null;
|
||||
|
||||
@IsDate
|
||||
@Column
|
||||
suspendedAt: Date | null;
|
||||
|
||||
// getters
|
||||
|
||||
/**
|
||||
* Returns whether the team has been suspended and is no longer accessible.
|
||||
*/
|
||||
get isSuspended(): boolean {
|
||||
return !!this.suspendedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the team has email login enabled. For self-hosted installs
|
||||
* this also considers whether SMTP connection details have been configured.
|
||||
|
||||
@@ -227,7 +227,7 @@ class User extends ParanoidModel {
|
||||
// getters
|
||||
|
||||
get isSuspended(): boolean {
|
||||
return !!this.suspendedAt;
|
||||
return !!this.suspendedAt || this.team?.isSuspended;
|
||||
}
|
||||
|
||||
get isInvited() {
|
||||
|
||||
@@ -32,8 +32,11 @@ export async function signIn(
|
||||
service: string,
|
||||
{ user, team, client, isNewTeam }: AuthenticationResult
|
||||
) {
|
||||
if (team.isSuspended) {
|
||||
return ctx.redirect("/?notice=team-suspended");
|
||||
}
|
||||
if (user.isSuspended) {
|
||||
return ctx.redirect("/?notice=suspended");
|
||||
return ctx.redirect("/?notice=user-suspended");
|
||||
}
|
||||
|
||||
if (isNewTeam) {
|
||||
|
||||
Reference in New Issue
Block a user