source: EWD/ewdapps/so/r/ewdu.m@ 1316

Last change on this file since 1316 was 1316, checked in by Sam Habiel, 12 years ago

Support for sending verify code in access code using ; m side

File size: 5.1 KB
Line 
1ewdu ; JJIH/SMH - Utilities for EWD to VISTA interaction ; 11/18/11 5:39pm
2 ;
3r(sessid) ; Restore Symbol Table
4 d mergeArrayFromSession^%zewdAPI(.DUZ,"DUZ",sessid)
5 d mergeArrayFromSession^%zewdAPI(.IO,"IO",sessid)
6 s U=$$getSessionValue^%zewdAPI("U",sessid)
7 quit
8 ;
9s(sessid) ; Save to Symbol Table
10 d mergeArrayToSession^%zewdAPI(.DUZ,"DUZ",sessid)
11 d mergeArrayToSession^%zewdAPI(.IO,"IO",sessid)
12 d setSessionValue^%zewdAPI("U","^",sessid)
13 quit
14 ;
15 ; Custom Tag
16SS(nodeOID,attrValues,docOID,technology) ; <vista:session> to get VISTA Session Variables
17 N attr
18 S attr("method")="r^ewdu"
19 S attr("param1")="#ewd_sessid"
20 S attr("type")="procedure"
21 N xOID s xOID=$$addElementToDOM^%zewdDOM("ewd:execute",nodeOID,"",.attr)
22 D removeIntermediateNode^%zewdDOM(nodeOID)
23 quit
24 ;
25NULL ; Open Null Device
26 s %ZIS="0H",IOP="NULL" d ^%ZIS
27 i POP s $ec=",U1," ; this crashes everything... intended...
28 q
29 ;
30SETUP(sessid) ; Set-up and SSO
31 ; TODO: Set IO("CLNM")
32 i '$data(IO) d NULL ; Open Null Device
33 s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
34 n return
35 d SETUP^XUSRB(.return) ; Set-up and Try SSO
36 i $g(return(5)),DUZ>0 q $$s(sessid) ; Single Sign-On Successful!
37 e d q "" ; Otherwise, get INTRO text
38 . N RET
39 . D INTRO^XUSRB(.RET)
40 . d mergeArrayToSession^%zewdAPI(.RET,"introtxt",sessid)
41 ; ---
42so(sessid) ; SO from EWD; routes to $$SO
43 ; TODO: Set IO("CLNM")
44 d NULL ; IO set-up
45 s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
46 d SETUP^XUSRB(); ; This time, just need partition set-up
47 n ac s ac=$$getSessionValue^%zewdAPI("ac",sessid)
48 n vc s vc=$$getSessionValue^%zewdAPI("vc",sessid)
49 n result s result=$$SO(ac,vc)
50 ;
51 ; Change Verify Code Logic Ahead... Damn Complex!
52 i $l(result),result="CVC" d q "" ; User must change Verify Code
53 . S DUZ=$$STATE^XWBSEC("XUS DUZ") ; VISTA kills off DUZ if vc needs changing.
54 . ; That's fine when it can get it back. But we are not a stateful process.
55 . ; By the time the second request is made, XUS DUZ is gone gone gone.
56 . d s(sessid) ; Save symbol table for next page (including DUZ)
57 . d setRedirect^%zewdAPI("cvc",sessid) ; Next page is cvc.
58 . d setSessionValue^%zewdAPI("cvcForced",1,sessid) ; Need to know that the user is toast!
59 ;
60 i $l(result) q result ; General Error Message - User can't log-in
61 ;
62 e d q "" ; Everything Okay
63 . d s(sessid)
64 . i $$isCheckboxOn^%zewdAPI("cvc","cvc",sessid) d setRedirect^%zewdAPI("cvc",sessid)
65 ;
66SO(ac,vc) ; Sign-on to VISTA, AV way
67 ; TODO: Handle the rest of the return values
68 N return
69 ; if ac contains ;, then it contains the verify code
70 ; else, send ac;vc
71 if ac[";" d VALIDAV^XUSRB(.return,$$ENCRYP^XUSRB1(ac))
72 else d VALIDAV^XUSRB(.return,$$ENCRYP^XUSRB1(ac_";"_vc))
73 i return(0)>0,'return(2) q "" ; Sign on successful!
74 i return(0)=0,return(2) q "CVC" ; Verify Code must be changed NOW!
75 i $l(return(3)) q return(3) ; Error Message returned whole
76 ; Note: division selection not implemented here
77 quit ""
78 ; ---
79sss(id) ; Test
80 d setRedirect^%zewdAPI("index",id,"bb")
81 q ""
82whoami(sessid) ; Who Am I? PrePage Script
83 d r(sessid)
84 n Name s Name=$$GET1^DIQ(200,DUZ,.01) ; User Name
85 d setSessionValue^%zewdAPI("Name",Name,sessid)
86 q ""
87cvc(sessid) ; Change Verify Code
88 ; get stored session values for DUZ, IO, and U
89 d r(sessid) ; Restore the Symbol Table
90 n VC1,VC2,VC3
91 s VC1=$$getPasswordValue^%zewdAPI("vc1",sessid)
92 s VC2=$$getPasswordValue^%zewdAPI("vc2",sessid)
93 s VC3=$$getPasswordValue^%zewdAPI("vc3",sessid)
94 ; Uppercase them -- otherwise CVC will fail.
95 s VC1=$$UP^XLFSTR(VC1)
96 s VC2=$$UP^XLFSTR(VC2)
97 s VC3=$$UP^XLFSTR(VC3)
98 ; Roman Cipher them vista-wise
99 n eVC1,eVC2,eVC3
100 s eVC1=$$ENCRYP^XUSRB1(VC1)
101 s eVC2=$$ENCRYP^XUSRB1(VC2)
102 s eVC3=$$ENCRYP^XUSRB1(VC3)
103 ; Set-up Call
104 n vcString s vcString=eVC1_U_eVC2_U_eVC3
105 n ret
106 d CVC^XUSRB(.ret,vcString)
107 i ret(0)=0 q "" ; Success
108 i ret(0)>0 q ret(1) ; Failure
109 ;;
110 ;;return(0)=0
111 ;;return(1)=0
112 ;;return(2)=1
113 ;;return(3)="VERIFY CODE must be changed before continued use."
114 ;;return(4)=0
115 ;;return(5)=0
116 ;;return(6)=""
117 ;;return(7)="Good evening DOCTOR,TEN"
118 ;;return(8)=" You last signed on today at 22:19"
119listEWDApps(sessid) ; Lists all available EWD Applicaitons, not including ewdMgr. Intended to be an imitation of a menu.
120 n apps ; Will hold our applications
121 do
122 . n ewdpath s ewdpath=^zewd("config","applicationRootPath")
123 . o "lsApps":(shell="/bin/bash":command="ls -1 "_ewdpath:READONLY)::"PIPE"
124 . u "lsApps"
125 . n line
126 . n counter s counter=1
127 . for read line quit:$zeof do
128 . . i line="ewdMgr" quit ; Don't include ewdMgr
129 . . s apps(counter)=line
130 . . s counter=counter+1
131 . c "lsApps"
132 . zwrite:$g(debug) apps
133 . d mergeArrayToSession^%zewdAPI(.apps,"installedapps",sessid)
134 ;
135 ; Old code: uses JSON
136 ; n appsjson s appsjson=$$arrayToJSON^%zewdJSON("apps")
137 ; zwrite:$g(debug) appsjson
138 ; d setSessionValue^%zewdAPI("appsjson",appsjson,sessid)
139 ;
140 q ""
141redir(sessid)
142 n redirapp s redirapp=$$getRequestValue^%zewdAPI("nextapp",sessid)
143 d setRedirect^%zewdAPI("index",sessid,redirapp)
144 q ""
145 ;
Note: See TracBrowser for help on using the repository browser.