authentication - How to check if user is authenticated in Service Stack Client? -


I hosted the service stack server myself in the client application, it is a Windows form, when the user is not authenticated I want to display the login form. To try and send a request like WebServiceException in a way

I for @if (Request.IsAuthenticated) (for example) Seeing for customer side

The short answer is that there is no way to determine the customer Whether the user is authentic or not state determines whether the client is authenticated or stored on the server.

A user is authenticated only if there is one. This session is usually sent in the HTTP client cookies which are populated after a successful authentication attempt, eg:

  var client = JsonServiceClient (BaseUrl); Var authResponse = client.Send (new authenticate {provider = credentials by provider name, user name = "user", password = "p @ 55word", random = true,});  

You can now use the same client (which has its cookie population) to create authenticated requests for the only services. Although note that if the user terminates the session for any reason, the client is no longer certified and will throw 401 unauthorized HTTP exceptions at the point where they have to be re-certified.

To certify and determine whether the user has been authenticated or not / auth , such as:

  $ GetJSON ("/ api / auth", function (r) {var html = " certified! & Lt; / h4 & gt;" + "& lt; table & gt; "+ $ .map (r, function (k, v) {return" <"> " + v + " th>" + "& lt; td & Gt; "+ + Td> & lt; / tr & gt;";}). Include ('') + "& lt; / table & gt;"; $ ("# position"). (Html);}} error. (Function () {$ ("#status"). Html ("& lt; h4 class = 'error' & gt; not certified ;); < / Code> 

S = i equals S:

  Try {var response = client.Get (authenticate new); // authenticated} hold ( WebServiceException) {// not authenticated}  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -