fix some other bugs of iam
This commit is contained in:
@@ -73,6 +73,13 @@ export class CustomerAuthController {
|
||||
return { logout_url: this.auth.centralLogoutUrl(returnUrl) };
|
||||
}
|
||||
|
||||
@CustomerAuth()
|
||||
@Post('auth/logout')
|
||||
@HttpCode(200)
|
||||
logout(@CurrentCustomer() me: AuthenticatedCustomer) {
|
||||
return this.auth.endSharedSessions(me.mobile);
|
||||
}
|
||||
|
||||
@CustomerAuth()
|
||||
@Get('me')
|
||||
me(@CurrentCustomer() me: AuthenticatedCustomer) {
|
||||
|
||||
@@ -608,6 +608,25 @@ export class CustomerAuthService {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* نشست IAM همین ورود را میبندد تا اپ دیگر هم با رفرش خارج شود.
|
||||
* شکست اینجا خروج محلی را متوقف نمیکند؛ پرش مرورگر به IAM هنوز کوکی را پاک میکند.
|
||||
*/
|
||||
async endSharedSessions(mobile: string): Promise<{ ended: number }> {
|
||||
if (!this.iam.enabled) return { ended: 0 };
|
||||
const ids = await this.sessions.activeIamSessionIds(mobile);
|
||||
let ended = 0;
|
||||
for (const id of ids) {
|
||||
try {
|
||||
await this.iam.endDelegatedSession(id);
|
||||
ended += 1;
|
||||
} catch (error) {
|
||||
this.logger.warn(`central sign-out skipped for ${id}: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
return { ended };
|
||||
}
|
||||
|
||||
private withBootstrap<T extends { token: string; customer: { id: string; mobile: string } }>(
|
||||
body: T,
|
||||
identity: IamIdentity | null,
|
||||
|
||||
Reference in New Issue
Block a user