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

Async implementation of the loadUserByUsername function of UserDetailsService #305

Open
mrf1989 opened this issue May 22, 2022 · 0 comments

Comments

@mrf1989
Copy link

mrf1989 commented May 22, 2022

Greetings! Below I share a little proposal to improve the framework, since the authentication system has not allowed me to continue developing a project that I am doing.

[Context]
I am developing a Rest API with Mandarine as framework (v2.3.2). When implementing the authentication system, I have to implement the loadUserByUsername function in order to obtain the user from the database.

loadUserByUsername returns UserDetails | undefined, so it doesn't allow my implementation to be something like this:

public async loadUserByUsername(username: string) {
     const user: Mandarine.Types.UserDetails = await this.usuarioRepository.getUsuarioByUsername(username);
     return user;
}

[Alternatives]
The idea is that loadUserByUsername could return Promise<UserDetails | undefined>, since I use MongoDB as the database and it returns a promise as a response to the query.

I have started from the v2.3.2 tag and I have modified three files that allow this implementation correctly. I haven't started from the master branch because it was throwing me several errors (possibly because of the version of Deno I'm using, v1.13.2).

You can see the commit with the modifications in the following branch: link to proposal

I would like to know if I could apply to PR so that it can be offered as a new version v2.3.3

What do you think about this change? I think it would allow better integration with many databases that return promises and implement asynchrony.

[Additional context]
This is the configuration of the development environment, since I have had to fit versions for it to work correctly.

This change would be of great help to me to be able to continue with the development of this small project.

My congratulations for the framework. I await comments.

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

1 participant