//Create access token by validating the Username and Password. public TokenResponse CreateAccessToken(string userName, string password) { var customer = _accountService.FindCustomerByUserName(userName); if (customer == null || !_passwordHasher.PasswordMatches(password, customer.Password)) { return(new TokenResponse(false, "Invalid UserName or Password.", null, null)); } else { var token = _tokenHandler.BuildAccessToken(customer); if (customer.LoginStatus == false) { var updated_customer = _accountService.LoginCustomer(customer); return(new TokenResponse(true, "Logged in Successfully.", token, updated_customer)); } else { return(new TokenResponse(true, "Logged in Successfully.", token, customer));; } } }