-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Custom NbAuthStrategy getting result from async call #2388
Comments
Try extend NbAuthStrategy: authenticate(data?: any): Observable<NbAuthResult> {
const module = 'login';
const method = this.getOption(`${module}.method`);
const url = this.getActionEndpoint(module);
const requireValidToken = this.getOption(`${module}.requireValidToken`);
return this.http.request(method, url, { body: data, observe: 'response', withCredentials: true })
.pipe(
map((res) => {
if (this.getOption(`${module}.alwaysFail`)) {
throw this.createFailResponse(data);
}
return res;
}),
map((res) => {
return new NbAuthResult(
true,
res,
this.getOption(`${module}.redirect.success`),
[],
this.getOption('messages.getter')(module, res, this.options),
this.createToken(this.getOption('token.getter')(module, res, this.options), requireValidToken));
}),
catchError((res) => {
return this.handleResponseError(res, module);
}),
);
} |
I got his working with your help Basically:
authenticate(user: UserData): Observable< NbAuthResult > {
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am creating my own authentication method. I have extended NbAuthStrategy and implemented method authenticate as shown below
the method is expected to return a Observable object.
When I do a memory authentication it works great, no issues.
The problem comes when I try to authenticate on an AWS Lambda by doing an async call. As the response is async, I cannot return Observable so I find this authentication mechanism only works for memory or synchronous calls.
How can I authenticate when validation is done on an async call?
The text was updated successfully, but these errors were encountered: