I have a field called CPF, which is an integer from a user document. How can I make a comparison with this number and log in safely?
I assume the CPF field is stored in a database table. Write a LINQ query to fetch the value alone with whatever else you need to validate the user.
ebiagi
What method of signInManager can I use?
The SingInManager does not know the CPF field exists. I guess you could store the CPF value as the username or password. Or maybe create a page where the user must enter the CPF field before the user can create an account?
The code you've shared above is confusing. It looks like the intention is to return a client token but also generate an authentication cookie. Can you explain the design intent and the type of application you building? What is the client in your design?
A browser? Code?
Member
2 Points
9 Posts
How to login the user through a field other than email or password - Web API Asp.Net Core
Mar 30, 2021 07:24 PM|ebiagi|LINK
Friends, I need to login the user through any field, other than email or password.
I am following this tutorial to create a web service.
[HttpPost("Login")] public async Task<ActionResult<UserToken>> Login([FromBody] UserInfo userInfo) { var result = await _signInManager.PasswordSignInAsync(userInfo.Email, userInfo.Password, isPersistent: false, lockoutOnFailure: false); if (result.Succeeded) { return BuildToken(userInfo); } else { ModelState.AddModelError(string.Empty, "Invalid Login"); return BadRequest(ModelState); } }
I have a field called CPF, which is an integer from a user document. How can I make a comparison with this number and log in safely?
What method of signInManager can I use?
I appreciate any comments!
All-Star
53641 Points
24012 Posts
Re: How to login the user through a field other than email or password - Web API Asp.Net Core
Mar 30, 2021 07:41 PM|mgebhard|LINK
I assume the CPF field is stored in a database table. Write a LINQ query to fetch the value alone with whatever else you need to validate the user.
The SingInManager does not know the CPF field exists. I guess you could store the CPF value as the username or password. Or maybe create a page where the user must enter the CPF field before the user can create an account?
The code you've shared above is confusing. It looks like the intention is to return a client token but also generate an authentication cookie. Can you explain the design intent and the type of application you building? What is the client in your design? A browser? Code?