0
我已在ServiceStack中实施CredentialsAuthProvider
身份验证。因此,我可以将UserAuth
和UserOAuthProvider
表创建到我的RDBMS中。我也有写服务注册用户。现在,当我试图使用http://localhost:64132/auth/credentials
URL来测试我的身份验证时,我可以做到这一点。另外我得到像如何在ServiceStack中使用凭据身份验证服务
{
"SessionId": "1",
"UserName": "Bond",
"ResponseStatus": {}
}
现在按我的要求,我通过Login
服务消费这个“http://localhost:64132/auth/credentials”,并获得响应的响应。在成功验证后,我希望我的Login
服务重定向到Home.html
页面。请帮我把它.I首次上ServiceStack framework.Thanks
更新工作..
公共类login服务:服务 {
public Object Any(Login loginRequest) {
//Here at this point call the Authentication URL from c# Client Service
loginRequest.UserName = "Bond";
loginRequest.Password = "password";
string BaseUrl = "http://localhost:64132/auth";
var client = new JsonServiceClient(BaseUrl);
string response="";
try
{
var authResponse = client.Send<AuthResponse>(new Auth
{
provider = CredentialsAuthProvider.Name,
UserName = loginRequest.UserName,
Password = loginRequest.Password,
RememberMe = true, //important tell client to retain permanent cookies
});
response = authResponse.ToString();
}
catch (Exception ex) {
}
感谢您的建议。我怀疑:ServiceStack中的身份验证仅用于服务,还是用于用户或帐户管理,我的意思是创建新用户,更改密码,删除等? – Lara
AuthFeature只是进行身份验证,您需要包含RegistrationFeature以启用为CredentialsAuth注册用户的服务,有关示例,请参阅[HttpBenchmarks身份验证文档](https://github.com/ServiceStackApps/HttpBenchmarks#authentication) 。 – mythz
这个我知道Mythz,我能够成功创建或注册用户。只有我在使用RegistrationFeature注册的凭证登录时遇到问题。我会再解释一点。我有一个登录服务,这是没有身份验证,以便所有用户都可以访问此服务。现在在此服务中,我正在传递注册的用户详细信息,如用户名,密码等,现在我想它给我成功或失败的登录响应用户传递的凭据。我用我的代码更新我的问题..请看看,并告诉我我要去哪里错了.. – Lara