@@ -86,8 +86,9 @@ Method ExecuteSQL(query As %String = "") As %Status
8686 quit $$$OK
8787}
8888
89- /// This method holds process and expects only one package from
90- /// the client - it includes authorization key.
89+ /// This method performs the authorization and login to WebTerminal.
90+ /// It returns a list with data (see Router.Auth method), which is used then to set up the
91+ /// initial values for the client.
9192Method RequireAuthorization () As %List
9293{
9394 set data = ..GetMessage (..#AuthorizationTimeout)
@@ -115,10 +116,13 @@ Method RequireAuthorization() As %List
115116 set username = $LISTGET (list , 1 )
116117 set namespace = $LISTGET (list , 3 )
117118 set ns = $Namespace
119+
118120 znspace " %SYS"
119121 do ##class (Security.Users ).Get (username , .userProps )
120122 znspace ns
121123
124+ set namespace = $case (namespace , " " :userProps (" NameSpace" ), :namespace )
125+
122126 if ($get (userProps (" Routine" )) '= " " ) {
123127 set ..StartupRoutine = userProps (" Routine" )
124128 }
@@ -127,14 +131,14 @@ Method RequireAuthorization() As %List
127131 return $LB (" User " _ username _ " is not enabled in the system" )
128132 }
129133
130- set namespace = $case ( namespace , " " : userProps ( " NameSpace " ), : namespace )
134+ set $LIST ( list , 3 ) = namespace
131135 set loginStatus = $System .Security .Login (username )
132136
133137 if (loginStatus '= 1 ) {
134138 return $LB ($System .Status .GetErrorText (loginStatus ))
135139 }
136140
137- return $LB (" " , namespace )
141+ return $LB (" " , list )
138142}
139143
140144/// See WebTerminal.Handlers
@@ -190,12 +194,13 @@ loopEnd
190194
191195/// This method sends basic login info to the user. Use this method to set client variables
192196/// during the WebTerminal initialization.
193- Method SendLoginInfo ()
197+ /// <parameter>authList</parameter> See Router.Auth method.
198+ Method SendLoginInfo (authList As %List )
194199{
195200 set obj = ##class (%ZEN.proxyObject ).%New ()
196201 set obj .username = $USERNAME
197202 set obj .name = $get (^WebTerminal (" Name" ))
198- set obj .cleanStart = $data ( ^WebTerminal ( " CleanStart " ) )
203+ set obj .cleanStart = $ListGet ( authList , 4 )
199204 set obj .system = $SYSTEM
200205 set obj .firstLaunch = ($get (^WebTerminal (" FirstLaunch" ), 1 ) '= 0 )
201206 set obj .InstanceGUID = ##class (%SYS.System ).InstanceGUID ()
@@ -207,15 +212,22 @@ Method SendLoginInfo()
207212/// Triggered when new connection established.
208213Method Server () As %Status
209214{
210- set authRes = ..RequireAuthorization () // $LB("", $Namespace)
215+ set authRes = ..RequireAuthorization ()
211216 set authMessage = $ListGet (authRes , 1 )
212217 if (authMessage = " " ) {
213- set namespace = $ListGet (authRes , 2 )
214- if (namespace '= " " ) {
215- try { znspace namespace } catch (e ) { }
218+ set authList = $ListGet (authRes , 2 ) // see Router.Auth method
219+ set namespace = $ListGet (authList , 3 )
220+ if (namespace '= " " ) && (namespace '= $Namespace ) {
221+ try {
222+ znspace namespace
223+ } catch (e ) {
224+ do ..Send (" oLocalized" ,
225+ $Char (27 ) _ " [31m%unNS(" _ namespace _ " )" _ $Char (27 ) _ " [0m" _ $Char (13 ,10 )
226+ )
227+ }
216228 }
217229 set ..CurrentNamespace = $Namespace
218- do ..SendLoginInfo ()
230+ do ..SendLoginInfo (authList )
219231 do ..ClientLoop ()
220232 do ..Send (" oLocalized" , " %wsNormalClose" _$C (13 ,10 ))
221233 } else {
0 commit comments