Skip to content

Commit

Permalink
fix: Explain why logging in will not work
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimvh committed Aug 18, 2021
1 parent f0f59a8 commit 30a460a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/identity/IdentityProviderHttpHandler.ts
Expand Up @@ -227,10 +227,9 @@ export class IdentityProviderHttpHandler extends HttpHandler {

if (result.type === 'complete') {
if (!oidcInteraction) {
// Once https://github.com/solid/community-server/pull/898 is merged
// we want to assign an error code here to have a more thorough explanation
throw new BadRequestHttpError(
'This action can only be executed as part of an authentication flow. It should not be used directly.',
'This action can only be performed as part of an OIDC authentication flow.',
{ errorCode: 'E0002' },
);
}
// Create a redirect URL with the OIDC library
Expand Down
6 changes: 6 additions & 0 deletions templates/error/descriptions/E0002.md.hbs
@@ -0,0 +1,6 @@
# Please log in through an app
Logging in to a Solid Pod needs to happen via a Solid app.
<br>
It is not possible to use the login page directly.
If you are developing an app,
you can use a library such as [`solid-client-authn-js`](https://github.com/inrupt/solid-client-authn-js) to initiate an OIDC authentication flow.
7 changes: 4 additions & 3 deletions test/unit/identity/IdentityProviderHttpHandler.test.ts
Expand Up @@ -160,9 +160,10 @@ describe('An IdentityProviderHttpHandler', (): void => {
expect(routes.complete.handler.handleSafe).toHaveBeenLastCalledWith({ operation });
expect(interactionCompleter.handleSafe).toHaveBeenCalledTimes(0);

const error = new BadRequestHttpError(
'This action can only be executed as part of an authentication flow. It should not be used directly.',
);
const error = expect.objectContaining({
message: 'This action can only be performed as part of an OIDC authentication flow.',
errorCode: 'E0002',
});
expect(errorHandler.handleSafe).toHaveBeenCalledTimes(1);
expect(errorHandler.handleSafe).toHaveBeenLastCalledWith({ error, preferences: { type: { 'text/html': 1 }}});
expect(responseWriter.handleSafe).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 30a460a

Please sign in to comment.