【发布时间】:2013-11-02 07:38:40
【问题描述】:
你好服务堆栈用户 -
下一个问题的 TL;DR 版本是这样的:使用 Servicestack 进行身份验证时,如何返回自定义身份验证响应?
我已经检查了一些关于此主题的先前 Stack 问题/答案,但我还没有想出最好的方法:
How can I extend ServiceStack Authentication 和 Return a custom auth response object from ServiceStack authentication
我想将此对象从 ServiceStack 返回到远程 JsonServiceClient:
public class MyGreatCustomAuthResponse : AuthResponse
{
public UserModel UserModel { get; set; }
}
我确实有一个客户端当前正在使用默认身份验证响应。我是这样做的:
var AuthResponse = client.Post(new Auth
{
provider = "credentials",
UserName = user.user_id,
Password = user.password,
RememberMe = true
});
我假设接受自定义响应的方式可能如下所示:
var AuthResponse = client.Post<MyGreatCustomResponse>(new CustomAuthRequest
{
provider = "credentials",
UserName = user.user_id,
Password = user.password,
RememberMe = true
});
//Use the UserModel object in the response for some other function on the client
var UserModel = AuthResponse.UserModel ;
这很容易吗?如果是这样,如何开始编写代码?
【问题讨论】:
标签: asp.net-mvc authentication servicestack