locked
which api functions I will need to make login ? RRS feed

  • Question

  • User696604810 posted

    problem

    which api functions I will need to make login ?

    i need to know function or action must be done to achieve login with full functionality as following :

    post 

    [HttpPost(Contracts.ApiRoutes.Login.UserLogin)]
    public  IActionResult PostUserLogins([FromBody]string username,[FromBody]string password)
            {
    * count attempt login and if exceed limit within in period lock account .
    
    * check password expiration 
    validate user and password 
    if(isvalid)
    return json
    else
    return json to failed
    
    generate access token
    
            }

    only if possible i need pseudo code to what i will do .

    make action to check expiredate password or make it inside function postuselogin and what nature get or post?

    count attempt login is this will be on separate action or inside function postuserlogin and what nature get or post ?

    validate user and password also and what nature of get or post ?

    generate access token and what nature ?

    the result expected as following json :

    {
    "request_status" : {
    "status" : "succeeded",
    "code": 0,
    "message" : "login succeeded!"
    },
    "access_token" : "",
    "user_data": { 
      "UserFullName" : "Ahmed", 
      "LoginTime" : "12", 
      "Admin" : "adil"
      
    },
    "branches": [
    { 
      "BranchCode" : "1",
      "BranchName":"Baha" 
      
    }
    ]
    }
    

    so how to write functions as above 

    public interface ISecurityService
        {
    what function here 
        }
     public class SecurityService : ISecurityService
        {
    what i write here  functions 
        }
     public class SecurityController : Controller
        {
            readonly Services.ISecurityService _SecurityService;
            public SecurityController(Services.ISecurityService securityService)
            {
                _SecurityService = securityService;
            }
    what i write here please type of action and functions 
        }

    Monday, September 2, 2019 1:08 AM

All replies

  • User711641945 posted

    Hi ahmedbarhary,

    public  IActionResult PostUserLogins([FromBody]string username,[FromBody]string password)

    You could not apply [FromBody] for more than one parameter per action method. And I have mentioned it in this thread.

    Then you could write logic to check expiredate password or count attempt login or validate user and password etc in the PostUserLogins action.It is a bit complex.Also you could split these functions and call them in PostUserLogins action. No need to add [HttpPost] or [HttpGet].I suggest that you could use filter.

    As I suggeted in this thread that you could add a LoginFailureCount property to save the failure count.And use filter to prevent the locked user from getting into the PostUserLogins action.

    Best Regards,

    Rena

    Monday, September 2, 2019 8:08 AM