Skip to content
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

docs: injection of current user may require optional set to true #3185

Merged
merged 1 commit into from
Jun 19, 2019

Conversation

emonddr
Copy link
Contributor

@emonddr emonddr commented Jun 19, 2019

Optional flag may need to be set to true when injecting
CURRENT_USER in a controller constructor if only
some controller methods are decorated with the
@authenticate decorator

Related to : #2940

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@emonddr emonddr requested review from jannyHou, nabdelgadir and agnes512 and removed request for raymondfeng and bajtos June 19, 2019 19:08
@@ -40,5 +40,8 @@ export class WhoAmIController {
}
```

{% include note.html content="If only <b>some</b> of the controller methods are decorated with the <b>@authenticate</b> decorator, then the injection decorator for CURRENT_USER in the controller's constructor must be specified as <b>@inject(AuthenticationBindings.CURRENT_USER, {optional:true})</b> to avoid a binding error when an unauthenticated endpoint is accessed. Alternatively, do not inject CURRENT_USER in the controller <b>constructor</b>, but in the controller <b>methods</b> which are actually decorated with the <b>@authenticate</b> decorator. See [Method Injection](../Dependency-injection.md#method-injection), [Constructor Injection](../Dependency-injection.md#constructor-injection) and [Optional Dependencies](../Dependency-injection.md#optional-dependencies) for details.
" %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you need the double quotation here for the markdown file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agnes512

Hi Agnes,

I followed the LoopBack documentation concerning documentation : tips, alerts, notes etc
https://loopback.io/doc/en/contrib/alerts.html

image

They use ".

But yes in javascript, ' can be used in place of " in most situations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the double quotation is necessary, since content=" begins with one.

Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 :shipit: LGTM

Optional flag may need to be set to true when injecting
CURRENT_USER in a controller constructor if only
some controller methods are decorated with the
@authenticate decorator
@emonddr emonddr force-pushed the dremond_docs_auth_optional_current_user branch from 6b36185 to 549e7ca Compare June 19, 2019 19:47
@emonddr emonddr merged commit 0d6fcfa into master Jun 19, 2019
@delete-merged-branch delete-merged-branch bot deleted the dremond_docs_auth_optional_current_user branch June 19, 2019 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants