ServiceStack - 自定义身份验证响应

时间:2015-10-30 10:54:08

标签: authentication servicestack response

ServiceStack - 自定义身份验证响应

1 个答案:

答案 0 :(得分:1)

AuthenticateResponseResponseStatus DTO都包含Meta字符串字典,您可以使用它来添加其他数据。

您可以使用Response Filter修改返回的AuthenticateResponse DTO,或覆盖AppHost中的OnAfterExecute()方法。

使用Global ResponseFilter

this.GlobalResponseFilters.Add((req, res, responseDto) => {
    var authResponse = responseDto as AuthenticateResponse;
    if (authResponse != null) {
        authResponse.Meta = new Dictionary<string,string> { 
            {"foo", "bar"} 
        };
    }
});
相关问题