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

Custom HTTPAuthentication: how to use getUser's callback with a null value for error #107

Open
jahjedtieson opened this issue Oct 28, 2021 · 2 comments

Comments

@jahjedtieson
Copy link

jahjedtieson commented Oct 28, 2021

HTTPAuthentication.getUser has a callback parameter with the signature callback: (error: Error, user?: webdav.IUser) => void. In typescript, it's not possible to call this method without supplying an Error, which in turn seems to signal that the request is not authenticated.

Should this signature be updated to callback: (error?: Error | null, user?: webdav.IUser) => void?

And if not, how do we call the callback to indicate that the request is authenticated?

@jahjedtieson
Copy link
Author

Note that I'm able to work around this with the comment // @ts-ignore: ts(2345) before calling the callback with a null Error ... but this shouldn't be necessary.

@a-nasstrom
Copy link

getUser(ctx, callback) {
const onError = (error) => {
callback(error, null);
};
// if error => {
onError(Errors_1.Errors.MissingAuthorisationHeader);
return;
}
// if no error => callback(null, mapUser);
};

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

No branches or pull requests

2 participants