Question: there are 5 column in 1st data frame . by using this find consecutive 1 from last D\_4 to D\_1, if find 0 in between then break and till that how many ones and that will be output

[![1st input data frame](https://i.stack.imgur.com/3I36k.png)](https://i.stack.imgur.com/3I36k.png)

[![2nd input data frame](https://i.stack.imgur.com/ApAN7.png)](https://i.stack.imgur.com/ApAN7.png)

[![output data frame](https://i.stack.imgur.com/u4enr.png)](https://i.stack.imgur.com/u4enr.png)

Answer: 
`SignInManager<TUser>.PasswordSignInAsync` Method Attempts to sign in the specified userName and password combination as an asynchronous operation and return `Task<SignInResult>`. for bearer token use `CheckPasswordAsync`.
its return a flag indicating whether the given password is valid for the specified user.

```
_userManager.CheckPasswordAsync(user, model.Password)

```

if user has valid creadintial then [generate the token](https://www.c-sharpcorner.com/article/jwt-token-authentication-and-authorizations-in-net-core-6-0-web-api/).

```
            if (user != null && await _userManager.CheckPasswordAsync(user, model.Password))
            {
                var userRoles = await _userManager.GetRolesAsync(user);

                var authClaims = new List<Claim>
                {
                    new Claim(ClaimTypes.Name, user.UserName),
                    new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
                };

                foreach (var userRole in userRoles)
                {
                    authClaims.Add(new Claim(ClaimTypes.Role, userRole));
                }

               var token = GetToken(authClaims);

                return Ok(new
                {
                    token = new JwtSecurityTokenHandler().WriteToken(token),
                    expiration = token.ValidTo
                });
            }

```

Ref: [Link1](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.signinmanager-1.passwordsigninasync?view=aspnetcore-6.0), [Link2](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.signinresult?view=aspnetcore-6.0), [Link3](https://stackoverflow.com/questions/53854051/usermanager-checkpasswordasync-vs-signinmanager-passwordsigninasync), [Link4](https://www.c-sharpcorner.com/article/jwt-token-authentication-and-authorizations-in-net-core-6-0-web-api/)
Depending how you want the client to store the token. If you want to deal with it in the client side you can `Return Ok(result.generatedToken)` but if you want to set it as a cookie I would recommend you to just Return Ok() but before that you set the cookie in the header of the response. You do this in the server

```
 // append cookie with token to the http response
        CookieOptions? cookieOptions = new()
        {
            HttpOnly = true,
            SameSite = SameSiteMode.Strict,
            Secure = true,
            Expires = ExpirationDate //it has to be a DateTime
        };
        Response.Cookies.Append("token", token, cookieOptions);

```

the advantage of doing it from the server is that you protect the token from being stolen by XSS injection or other attacks since the token is not accessable from javascript and can only be used in HTTPrequests.