Question
· Jun 26, 2020

How to disable the login prompt when csp session is expired and just return http status 401?

I am working on an angular applications and build a web application (Rest API) on IRIS for health, the web application uses a password authentication and setup with the default csp session time out (15 minutes). If the user make an REST API call from the angular application after the session expired, it displays a login prompt...is that anyway that we can disable the login prompt and just simply return http status 401?  When the angular application received the status 401, it can redirect to angular error page.

Thanks,

Hoi

Discussion (5)0
Log in or sign up to continue

I am not sure if I quite following you...I added the line that you suggested but I still got the login prompt when the session is expired.

Class ABC.KAT.Service.RestApiService Extends %CSP.REST
{ Parameter UseSession As Integer = 1; Parameter HandleCorsRequest = 1; XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap]
{
<Routes>
<Route Url="/Record/:schema/:table/:id" Method="GET" Call="Record" />
</Routes>
}
ClassMethod Record(schema As %String, table As %String, id As %Integer) As %Status
{
#dim eException As %Exception.AbstractException
#dim tSC As %Status = $$$OK
Try 
{
Set %response.ContentType="application/json"
do %response.SetHeader("WWW-Authenticate","Basic")
set className = "ABC.KAT.Data."_schema_"."_table
set tRS = $CLASSMETHOD(className, "%OpenId", id)
set jsonstring =""
$$$THROWONERROR(tSC,tRS.%JSONExportToString(.jsonstring))
set tResult = ##class(%DynamicObject).%FromJSON(jsonstring)
write tResult.%ToJSON()
}
  Catch eException
  {
Set tSC = eException.AsStatus()
  }
Quit tSC
} }
 

@Hoi Lai , I am trying to achieve something similiar to you i guess, I have a application in Vuejs, hosted on IRIS, using a web application, I am looking to create a login page on over it, which uses a basic HealthShare login credentials to log in the user. 

Can you please let me know, Is there something needs to be done on the frontend side as well. or is there an option to somehow use the basic healtshare login page which comes on opening the Management portal.