🐛Do not show anonymous user is the user list everywhere on UI (#182)
* 🐛Do not show anonymous user is the user list everywhere on UI
This commit is contained in:
@@ -557,7 +557,7 @@ export class DocumentsController {
|
||||
if (!document || !document.access || document.access === "none")
|
||||
throw new CrudException("You don't have access to this document", 401);
|
||||
|
||||
const email = `anonymous@${document.item.company_id}.tdrive.com`;
|
||||
const email = `anonymous@tdrive.${document.item.company_id}.com`;
|
||||
let user = await globalResolver.services.users.getByEmail(email);
|
||||
if (!user) {
|
||||
user = (
|
||||
@@ -568,9 +568,12 @@ export class DocumentsController {
|
||||
email_canonical: email,
|
||||
username_canonical: (email.replace("@", ".") || "").toLocaleLowerCase(),
|
||||
phone: "",
|
||||
// TODO fix the identity provider after creating migration script mechanics,
|
||||
// this is user type of the user account and not the provider
|
||||
identity_provider: "anonymous",
|
||||
identity_provider_id: email,
|
||||
mail_verified: true,
|
||||
type: "anonymous",
|
||||
}),
|
||||
)
|
||||
).entity;
|
||||
|
||||
@@ -4,6 +4,7 @@ import search from "./user.search";
|
||||
import { uuid } from "../../../utils/types";
|
||||
|
||||
export const TYPE = "user";
|
||||
export type UserType = "anonymous" | "tech" | "regular";
|
||||
|
||||
@Entity(TYPE, {
|
||||
primaryKey: [["id"]],
|
||||
@@ -92,6 +93,9 @@ export default class User {
|
||||
@Column("timezone", "string")
|
||||
timezone: string; //Depreciated (php legacy)
|
||||
|
||||
@Column("type", "string")
|
||||
type: UserType;
|
||||
|
||||
@Column("preferences", "encoded_json")
|
||||
preferences: null | {
|
||||
locale?: string;
|
||||
|
||||
@@ -163,18 +163,23 @@ export class UserServiceImpl {
|
||||
options?: SearchUserOptions,
|
||||
context?: ExecutionContext,
|
||||
): Promise<ListResult<User>> {
|
||||
return await this.searchRepository.search(
|
||||
{},
|
||||
{
|
||||
pagination,
|
||||
...(options.companyId ? { $in: [["companies", [options.companyId]]] } : {}),
|
||||
...(options.workspaceId ? { $in: [["workspaces", [options.workspaceId]]] } : {}),
|
||||
$text: {
|
||||
$search: options.search,
|
||||
return await this.searchRepository
|
||||
.search(
|
||||
{},
|
||||
{
|
||||
pagination,
|
||||
...(options.companyId ? { $in: [["companies", [options.companyId]]] } : {}),
|
||||
...(options.workspaceId ? { $in: [["workspaces", [options.workspaceId]]] } : {}),
|
||||
$text: {
|
||||
$search: options.search,
|
||||
},
|
||||
},
|
||||
},
|
||||
context,
|
||||
);
|
||||
context,
|
||||
)
|
||||
.then(users => {
|
||||
users.filterEntities(u => u.identity_provider != "anonymous" && u.type != "anonymous");
|
||||
return users;
|
||||
});
|
||||
}
|
||||
|
||||
async list(
|
||||
|
||||
Reference in New Issue
Block a user