How do I redirect after authentication in ServiceStack

后端 未结 2 1901
心在旅途
心在旅途 2021-02-08 18:40

I\'ve overridden the CredentialsAuthProvider like so:

public override bool TryAuthenticate(IServiceBase authService, string userName, string password)
        {
         


        
2条回答
  •  灰色年华
    2021-02-08 19:35

    The different places where you can set the Url to redirect to during ServiceStack Authentication, in order of precedence are:

    1. The Continue QueryString, FormData or Request DTO variable when making the request to /auth
    2. The Session.ReferrerUrl Url
    3. The HTTP Referer HTTP Header
    4. The CallbackUrl in the AuthConfig of the current AuthProvider used

    Given these order of preferences, if the request didn't have a Continue parameter, it should use the session.ReferrerUrl, so you could do:

    if (roleA) session.ReferrerUrl = "http://myPage1Url";
    if (roleB) session.ReferrerUrl = "http://myPage2Url";
    

提交回复
热议问题