2015-09-18 58 views
0

我已在ServiceStack中实施CredentialsAuthProvider身份验证。因此,我可以将UserAuthUserOAuthProvider表创建到我的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) { 

     } 

回答

1

我已经回答了这个问题为您在this previous answer列出每个重定向选项,例如,您可以在验证时使用?Continue=/Home请求参数。

+0

感谢您的建议。我怀疑:ServiceStack中的身份验证仅用于服务,还是用于用户或帐户管理,我的意思是创建新用户,更改密码,删除等? – Lara

+0

AuthFeature只是进行身份验证,您需要包含RegistrationFeature以启用为CredentialsAuth注册用户的服务,有关示例,请参阅[HttpBenchmarks身份验证文档](https://github.com/ServiceStackApps/HttpBenchmarks#authentication) 。 – mythz

+0

这个我知道Mythz,我能够成功创建或注册用户。只有我在使用RegistrationFeature注册的凭证登录时遇到问题。我会再解释一点。我有一个登录服务,这是没有身份验证,以便所有用户都可以访问此服务。现在在此服务中,我正在传递注册的用户详细信息,如用户名,密码等,现在我想它给我成功或失败的登录响应用户传递的凭据。我用我的代码更新我的问题..请看看,并告诉我我要去哪里错了.. – Lara