C
C#2y ago
Obel

❔ Retrieving a token from a login function

Im currently supposed to login from one endpoint, and retrieve extra user information from another, i need to return both a token and the user data with just one responseObject. The token is needed to retrieve the userinformation, I currently have a LoginService that returns a token on a succesful login, how can i ''merge'' the 2 pieces of information, and return it as one responseObject?
2 Replies
TheForgottenMaverick
You can create a model "LoginResponse" which will have both token and the responseObject object as its properties. For example -
public class LoginResponseDto
{
public User User { get; set; }
public string Token { get; set; }
}
public class LoginResponseDto
{
public User User { get; set; }
public string Token { get; set; }
}
I'm using the above model in a personal project I'm working on.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server