mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-13 17:35:12 +00:00
feat(console): integrate frontend (#95)
* feat: console frontend * chore(dependabot): cycle and npm * chore: rename citadel to zitadel, remove generated files * chore: delete go files * chore(frontend): ci steps * chore: remove docker and envoy files * chore: remove docker file * chore: working dir * chore: run proto build * add console start * chore: restructure folders * chore: remove gui build * statikFs * generate proto for console * add statik import * import * chore: try statik * chore: path * chore: path * chore: script in root * chore: order build steps * chore: go get * chore: folder traversal * chore: non empty test file * chore: gitignore * chore: gitignore * chore: statik path * chore: switch to failing FE build * fix: build * fix: project-grant-test * fix: rm test * add statik.go * go mod tidy * chore: place test, seperate test from build * chore: lint all the world * chore: ci the world instead * chore: tune docker * chore: undo container test * chore: fix run * chore: docker build * chore: test docker build * chore: go build flags * finaly * fix caos_local * go mod Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
co-authored by
Livio Amstutz
Max Peintner
parent
9e32740eb8
commit
92a294f5c8
@@ -0,0 +1,377 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { ManagementServicePromiseClient } from '../proto/generated/management_grpc_web_pb';
|
||||
import {
|
||||
ChangeRequest,
|
||||
Changes,
|
||||
CreateUserRequest,
|
||||
NotificationType,
|
||||
PasswordRequest,
|
||||
ProjectGrantMemberSearchQuery,
|
||||
ProjectGrantMemberSearchRequest,
|
||||
ProjectGrantMemberSearchResponse,
|
||||
ProjectRoleAdd,
|
||||
SetPasswordNotificationRequest,
|
||||
UpdateUserAddressRequest,
|
||||
UpdateUserEmailRequest,
|
||||
UpdateUserPhoneRequest,
|
||||
UpdateUserProfileRequest,
|
||||
User,
|
||||
UserAddress,
|
||||
UserEmail,
|
||||
UserEmailID,
|
||||
UserGrant,
|
||||
UserGrantCreate,
|
||||
UserGrantSearchQuery,
|
||||
UserGrantSearchRequest,
|
||||
UserGrantSearchResponse,
|
||||
UserID,
|
||||
UserPhone,
|
||||
UserProfile,
|
||||
UserSearchQuery,
|
||||
UserSearchRequest,
|
||||
UserSearchResponse,
|
||||
} from '../proto/generated/management_pb';
|
||||
import { GrpcBackendService } from './grpc-backend.service';
|
||||
import { GrpcService, RequestFactory, ResponseMapper } from './grpc.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MgmtUserService {
|
||||
constructor(private grpcService: GrpcService, private grpcBackendService: GrpcBackendService) { }
|
||||
|
||||
public async request<TReq, TResp, TMappedResp>(
|
||||
requestFn: RequestFactory<ManagementServicePromiseClient, TReq, TResp>,
|
||||
request: TReq,
|
||||
responseMapper: ResponseMapper<TResp, TMappedResp>,
|
||||
metadata?: Metadata,
|
||||
): Promise<TMappedResp> {
|
||||
const mappedRequestFn = requestFn(this.grpcService.mgmt).bind(this.grpcService.mgmt);
|
||||
const response = await this.grpcBackendService.runRequest(
|
||||
mappedRequestFn,
|
||||
request,
|
||||
metadata,
|
||||
);
|
||||
return responseMapper(response);
|
||||
}
|
||||
|
||||
public async CreateUser(user: CreateUserRequest.AsObject): Promise<User> {
|
||||
const req = new CreateUserRequest();
|
||||
req.setEmail(user.email);
|
||||
req.setUserName(user.userName);
|
||||
req.setFirstName(user.firstName);
|
||||
req.setLastName(user.lastName);
|
||||
req.setNickName(user.nickName);
|
||||
req.setDisplayName(user.displayName);
|
||||
req.setPassword(user.password);
|
||||
req.setPreferredLanguage(user.preferredLanguage);
|
||||
req.setGender(user.gender);
|
||||
req.setPhone(user.phone);
|
||||
req.setStreetAddress(user.streetAddress);
|
||||
req.setPostalCode(user.postalCode);
|
||||
req.setLocality(user.locality);
|
||||
req.setRegion(user.region);
|
||||
req.setCountry(user.country);
|
||||
return await this.request(
|
||||
c => c.createUser,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserProfile(id: string): Promise<UserProfile> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserProfile,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveUserProfile(profile: UserProfile.AsObject): Promise<UserProfile> {
|
||||
const req = new UpdateUserProfileRequest();
|
||||
req.setId(profile.id);
|
||||
req.setFirstName(profile.firstName);
|
||||
req.setLastName(profile.lastName);
|
||||
req.setNickName(profile.nickName);
|
||||
req.setDisplayName(profile.displayName);
|
||||
req.setPreferredLanguage(profile.preferredLanguage);
|
||||
req.setGender(profile.gender);
|
||||
return await this.request(
|
||||
c => c.updateUserProfile,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserEmail(id: string): Promise<UserEmail> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserEmail,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveUserEmail(email: UserEmail.AsObject): Promise<UserEmail> {
|
||||
const req = new UpdateUserEmailRequest();
|
||||
req.setId(email.id);
|
||||
req.setEmail(email.email);
|
||||
return await this.request(
|
||||
c => c.changeUserEmail,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserPhone(id: string): Promise<UserPhone> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserPhone,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveUserPhone(phone: UserPhone.AsObject): Promise<UserPhone> {
|
||||
const req = new UpdateUserPhoneRequest();
|
||||
req.setId(phone.id);
|
||||
req.setPhone(phone.phone);
|
||||
return await this.request(
|
||||
c => c.changeUserPhone,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async DeactivateUser(id: string): Promise<UserPhone> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.deactivateUser,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreateUserGrant(
|
||||
projectId: string,
|
||||
userId: string,
|
||||
roleNamesList: string[],
|
||||
): Promise<UserGrant> {
|
||||
const req = new UserGrantCreate();
|
||||
req.setProjectId(projectId);
|
||||
req.setUserId(userId);
|
||||
req.setRoleKeysList(roleNamesList);
|
||||
|
||||
return await this.request(
|
||||
c => c.createUserGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ReactivateUser(id: string): Promise<UserPhone> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.reactivateUser,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async AddRole(id: string, key: string, displayName: string, group: string): Promise<Empty> {
|
||||
const req = new ProjectRoleAdd();
|
||||
req.setId(id);
|
||||
req.setKey(key);
|
||||
req.setDisplayName(displayName);
|
||||
req.setGroup(group);
|
||||
return await this.request(
|
||||
c => c.addProjectRole,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserAddress(id: string): Promise<UserAddress> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserAddress,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ResendEmailVerification(id: string): Promise<any> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.resendEmailVerificationMail,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ResendPhoneVerification(id: string): Promise<any> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.resendPhoneVerificationCode,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SetInitialPassword(id: string, password: string): Promise<any> {
|
||||
const req = new PasswordRequest();
|
||||
req.setId(id);
|
||||
req.setPassword(password);
|
||||
return await this.request(
|
||||
c => c.setInitialPassword,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SendSetPasswordNotification(id: string, type: NotificationType): Promise<any> {
|
||||
const req = new SetPasswordNotificationRequest();
|
||||
req.setId(id);
|
||||
req.setType(type);
|
||||
return await this.request(
|
||||
c => c.sendSetPasswordNotification,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveUserAddress(address: UserAddress.AsObject): Promise<UserAddress> {
|
||||
const req = new UpdateUserAddressRequest();
|
||||
req.setId(address.id);
|
||||
req.setStreetAddress(address.streetAddress);
|
||||
req.setPostalCode(address.postalCode);
|
||||
req.setLocality(address.locality);
|
||||
req.setRegion(address.region);
|
||||
req.setCountry(address.country);
|
||||
return await this.request(
|
||||
c => c.updateUserAddress,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchProjectGrantMembers(
|
||||
limit: number,
|
||||
offset: number,
|
||||
query?: ProjectGrantMemberSearchQuery[],
|
||||
): Promise<ProjectGrantMemberSearchResponse> {
|
||||
const req = new ProjectGrantMemberSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (query) {
|
||||
req.setQueriesList(query);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchProjectGrantMembers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchUsers(limit: number, offset: number, queryList?: UserSearchQuery[]): Promise<UserSearchResponse> {
|
||||
const req = new UserSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchUsers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserByEmailGlobal(email: string): Promise<User> {
|
||||
const req = new UserEmailID();
|
||||
req.setEmail(email);
|
||||
return await this.request(
|
||||
c => c.getUserByEmailGlobal,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchUserGrants(
|
||||
limit: number,
|
||||
offset: number,
|
||||
queryList?: UserGrantSearchQuery[],
|
||||
): Promise<UserGrantSearchResponse> {
|
||||
const req = new UserGrantSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchUserGrants,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ApplicationChanges(id: string, limit: number, offset: number): Promise<Changes> {
|
||||
const req = new ChangeRequest();
|
||||
req.setId(id);
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(offset);
|
||||
return await this.request(
|
||||
c => c.applicationChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async OrgChanges(id: string, limit: number, offset: number): Promise<Changes> {
|
||||
const req = new ChangeRequest();
|
||||
req.setId(id);
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(offset);
|
||||
return await this.request(
|
||||
c => c.orgChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ProjectChanges(id: string, limit: number, offset: number): Promise<Changes> {
|
||||
const req = new ChangeRequest();
|
||||
req.setId(id);
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(offset);
|
||||
return await this.request(
|
||||
c => c.projectChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UserChanges(id: string, limit: number, sequenceoffset: number): Promise<Changes> {
|
||||
const req = new ChangeRequest();
|
||||
req.setId(id);
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(sequenceoffset);
|
||||
return await this.request(
|
||||
c => c.userChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user