mirror of
https://github.com/docmost/docmost.git
synced 2026-05-23 10:42:42 +08:00
WIP
This commit is contained in:
@@ -716,5 +716,12 @@
|
|||||||
"Unknown device": "Unknown device",
|
"Unknown device": "Unknown device",
|
||||||
"No active sessions": "No active sessions",
|
"No active sessions": "No active sessions",
|
||||||
"Session revoked": "Session revoked",
|
"Session revoked": "Session revoked",
|
||||||
"All other sessions revoked": "All other sessions revoked"
|
"All other sessions revoked": "All other sessions revoked",
|
||||||
|
"Last used": "Last used",
|
||||||
|
"Created": "Created",
|
||||||
|
"Rename": "Rename",
|
||||||
|
"Publish": "Publish",
|
||||||
|
"Security": "Security",
|
||||||
|
"Enforce SSO": "Enforce SSO",
|
||||||
|
"Once enforced, members will not be able to login with email and password.": "Once enforced, members will not be able to login with email and password."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ export class AuthController {
|
|||||||
setAuthCookie(res: FastifyReply, token: string) {
|
setAuthCookie(res: FastifyReply, token: string) {
|
||||||
res.setCookie('authToken', token, {
|
res.setCookie('authToken', token, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
|
sameSite: 'lax',
|
||||||
path: '/',
|
path: '/',
|
||||||
expires: this.environmentService.getCookieExpiresIn(),
|
expires: this.environmentService.getCookieExpiresIn(),
|
||||||
secure: this.environmentService.isHttps(),
|
secure: this.environmentService.isHttps(),
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ export class SessionService {
|
|||||||
const mapped = sessions.map((s) => ({
|
const mapped = sessions.map((s) => ({
|
||||||
id: s.id,
|
id: s.id,
|
||||||
deviceName: s.deviceName,
|
deviceName: s.deviceName,
|
||||||
ipAddress: s.ipAddress,
|
|
||||||
geoLocation: s.geoLocation,
|
geoLocation: s.geoLocation,
|
||||||
lastActiveAt: s.lastActiveAt,
|
lastActiveAt: s.lastActiveAt,
|
||||||
createdAt: s.createdAt,
|
createdAt: s.createdAt,
|
||||||
|
|||||||
@@ -669,13 +669,15 @@ export class WorkspaceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.userRepo.updateUser(
|
await executeTx(this.db, async (trx) => {
|
||||||
{ deactivatedAt: new Date() },
|
await this.userRepo.updateUser(
|
||||||
userId,
|
{ deactivatedAt: new Date() },
|
||||||
workspaceId,
|
userId,
|
||||||
);
|
workspaceId,
|
||||||
|
trx,
|
||||||
await this.userSessionRepo.revokeByUserId(userId, workspaceId);
|
);
|
||||||
|
await this.userSessionRepo.revokeByUserId(userId, workspaceId, trx);
|
||||||
|
});
|
||||||
|
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
event: AuditEvent.USER_DEACTIVATED,
|
event: AuditEvent.USER_DEACTIVATED,
|
||||||
@@ -789,9 +791,9 @@ export class WorkspaceService {
|
|||||||
await this.watcherRepo.deleteByUserAndWorkspace(userId, workspaceId, {
|
await this.watcherRepo.deleteByUserAndWorkspace(userId, workspaceId, {
|
||||||
trx,
|
trx,
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
await this.userSessionRepo.revokeByUserId(userId, workspaceId);
|
await this.userSessionRepo.revokeByUserId(userId, workspaceId, trx);
|
||||||
|
});
|
||||||
|
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
event: AuditEvent.USER_DELETED,
|
event: AuditEvent.USER_DELETED,
|
||||||
|
|||||||
+1
@@ -20,6 +20,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|||||||
col.notNull().defaultTo(sql`now()`),
|
col.notNull().defaultTo(sql`now()`),
|
||||||
)
|
)
|
||||||
.addColumn('expires_at', 'timestamptz', (col) => col.notNull())
|
.addColumn('expires_at', 'timestamptz', (col) => col.notNull())
|
||||||
|
.addColumn('metadata', 'jsonb')
|
||||||
.addColumn('revoked_at', 'timestamptz')
|
.addColumn('revoked_at', 'timestamptz')
|
||||||
.addColumn('created_at', 'timestamptz', (col) =>
|
.addColumn('created_at', 'timestamptz', (col) =>
|
||||||
col.notNull().defaultTo(sql`now()`),
|
col.notNull().defaultTo(sql`now()`),
|
||||||
@@ -89,8 +89,10 @@ export class UserSessionRepo {
|
|||||||
async revokeByUserId(
|
async revokeByUserId(
|
||||||
userId: string,
|
userId: string,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
|
trx?: KyselyTransaction,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await this.db
|
const db = dbOrTx(this.db, trx);
|
||||||
|
await db
|
||||||
.updateTable('userSessions')
|
.updateTable('userSessions')
|
||||||
.set({ revokedAt: new Date() })
|
.set({ revokedAt: new Date() })
|
||||||
.where('userId', '=', userId)
|
.where('userId', '=', userId)
|
||||||
|
|||||||
+1
@@ -437,6 +437,7 @@ export interface UserSessions {
|
|||||||
userAgent: string | null;
|
userAgent: string | null;
|
||||||
ipAddress: string | null;
|
ipAddress: string | null;
|
||||||
geoLocation: string | null;
|
geoLocation: string | null;
|
||||||
|
metadata: Json | null;
|
||||||
lastActiveAt: Generated<Timestamp>;
|
lastActiveAt: Generated<Timestamp>;
|
||||||
expiresAt: Timestamp;
|
expiresAt: Timestamp;
|
||||||
revokedAt: Timestamp | null;
|
revokedAt: Timestamp | null;
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: ebf891554c...759e109708
Reference in New Issue
Block a user