-
Notifications
You must be signed in to change notification settings - Fork 400
feat: add i18n support for password expired errors #20768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+77
−6
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
QA stepsChanging password expiration rules for testing purpose (can be tricky - since targets all system users). Workaround for handing this can be following:
import {
HttpErrorResponse,
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
/**
* This interceptor is used to mock HTTP responses for specific API endpoints.
*
* It intercepts HTTP requests and returns mock data for the defined endpoints,
* while allowing other requests to pass through unmodified.
*
* To use this interceptor, provide it in your Angular module's providers array.
* Example ([in app.module.ts](https://github.com/SAP/spartacus/blob/20b375201f22ecdff1ad850bccbae763969102a5/projects/storefrontapp/src/app/app.module.ts#L68)):
* {
* provide: HTTP_INTERCEPTORS,
* useExisting: MockInterceptor,
* multi: true,
* }
*/
@Injectable({ providedIn: 'root' })
export class MockInterceptor implements HttpInterceptor {
intercept(
req: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
// Define the API endpoint you want to mock
const OAUTH_ENDPOINT = '/authorizationserver/oauth/token';
const mockUrl = OAUTH_ENDPOINT;
if (req.url.endsWith(mockUrl)) {
// Return mock data as an HTTP response
const mockResponse = new HttpErrorResponse({
status: 400,
error: {
error: 'invalid_grant',
// error_description: "Bad credentials",
error_description: 'Password expired for the user: John Doe',
},
url: req.url,
});
// Use throwError to simulate an error response
return throwError(() => mockResponse);
}
// Pass through other requests unmodified
return next.handle(req);
}
}
Alternatively you could follow the description of https://jira.tools.sap/browse/CXSPA-10815 to see how to change Password expiration rule in Backoffice (but that can affect others if done on shared system). So above is safer for me. |
Contributor
Merge Checks Failed |
spartacus
|
||||||||||||||||||||||||||||
| Project |
spartacus
|
| Branch Review |
feature/CXSPA-10815
|
| Run status |
|
| Run duration | 03m 32s |
| Commit |
|
| Committer | Uros Lates |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
4
|
|
|
0
|
|
|
0
|
|
|
101
|
| View all changes introduced in this branch ↗︎ | |
rmch91
previously approved these changes
Nov 5, 2025
rmch91
previously approved these changes
Nov 6, 2025
rmch91
approved these changes
Nov 7, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes https://jira.tools.sap/browse/CXSPA-10815