-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add API for standalone and functional approaches #445
Conversation
*/ | ||
export const authHttpInterceptorFn = ( | ||
req: HttpRequest<any>, | ||
handle: (req: HttpRequest<unknown>) => Observable<HttpEvent<unknown>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we have no access to Angular15, we can not type this as HttpHandlerFn yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you mean HttpInterceptorFn
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, HttpHandlerFn. The second argument (it's called next in the Angular source code, handle in our code tho) of the interceptor is of type HttpHandlerFn, see: https://github.com/angular/angular/blob/febf29dd5197f8943e6377a8fc66a14b3a1c5973/packages/common/http/src/interceptor.ts#L90
export const authGuardFn = ( | ||
route: ActivatedRouteSnapshot, | ||
state: RouterStateSnapshot | ||
) => inject(AuthGuard).canActivate(route, state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only uses canActivate. However, canActivate
and canActivateChild
are identical implementation wise. So people can use authGuardFn for both scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, added a minor comment but shouldn't block merge imo
* Initialize the authentication system. Configuration can either be specified here, | ||
* or by calling AuthClientConfig.set (perhaps from an APP_INITIALIZER factory function). | ||
* | ||
* Note: Should only be used as of Angular 15, and should not be added to a component's providers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anyway we can have this as a check in the code and throw an error?
Description
Adds syntactic sugar to work better with standalone and functional approaches.
Note: This should only be used with Angular 15.
References
#444
#442
Testing
Checklist