api enableStatus
This commit is contained in:
parent
f05c2f4b63
commit
d613637c95
2 changed files with 46 additions and 7 deletions
|
|
@ -29,6 +29,7 @@ import {
|
|||
removeUserRoles,
|
||||
getRoleMappings,
|
||||
getUserCount,
|
||||
enableStatus,
|
||||
} from "../keycloak";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { Profile } from "../entities/Profile";
|
||||
|
|
@ -50,7 +51,6 @@ function stripLeadingSlash(str: string) {
|
|||
@Tags("Single-Sign On")
|
||||
@Security("bearerAuth")
|
||||
export class KeycloakController extends Controller {
|
||||
|
||||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ export class KeycloakController extends Controller {
|
|||
},
|
||||
});
|
||||
|
||||
if (profile) {
|
||||
if (profile) {
|
||||
profile.keycloak = userId;
|
||||
await this.profileRepo.save(profile);
|
||||
}
|
||||
|
|
@ -191,9 +191,9 @@ export class KeycloakController extends Controller {
|
|||
id: userId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (profile) {
|
||||
const null_:any = null;
|
||||
const null_: any = null;
|
||||
profile.keycloak = null_;
|
||||
await this.profileRepo.save(profile);
|
||||
}
|
||||
|
|
@ -254,6 +254,7 @@ export class KeycloakController extends Controller {
|
|||
lastname: x.lastName,
|
||||
email: x.email,
|
||||
roles: roles,
|
||||
enabled: x.enabled,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
@ -314,4 +315,10 @@ export class KeycloakController extends Controller {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Put("user/{userId}/enableStatus/{status}")
|
||||
async changeEnableStatus(@Path() userId: string, @Path() status: boolean) {
|
||||
const result = await enableStatus(userId, status);
|
||||
if (!result) throw new Error("Failed. Cannot change enable status.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue