Constructor
new SessionClient(ssInf, iv, dontPersist)
Create SessionClient with credential information or load from localStorage.
Because of two senarios of login / home page integration, there are 2 typical useses:
Use Case 1 (persisted): logged in, then create a client with response, save in local storage, then load it in new page.
Use Case 1 (not persisted): logged in, then create a client with response, user's app handled the object, then provided to other functions,
typicall a home.vue component.
Because of two senarios of login / home page integration, there are 2 typical useses:
Use Case 1 (persisted): logged in, then create a client with response, save in local storage, then load it in new page.
Use Case 1 (not persisted): logged in, then create a client with response, user's app handled the object, then provided to other functions,
typicall a home.vue component.
Note
Local storage may be sometimes confusing if not familiar with W3C standars.
The local storage can't be cross domain referenced. It's can not been loaded by home page
if you linked from login page like this, as showed by this example in login.vue:
window.top.location = response.home
One recommended practice is initializing home.vue with login credential by login.vue, in app.vue.
But this design makes home page and login component integrated. It's not friedly to application pattern like a port page with login which is independent to the system background home page.
How should this pattern can be improved is open for discussion. If your are interested in this subject, leave any comments in wiki page please.
Parameters:
Name | Type | Description |
---|---|---|
ssInf |
object | login response form server: {ssid, uid} |
iv |
Array.<byte> | iv used for cipher when login. |
dontPersist |
boolean | don't save into local storage. |
- Source:
Methods
commit(jmsg, onOk, onError)
Post the request message (JMessage with body of subclass of JBody).
Parameters:
Name | Type | Description |
---|---|---|
jmsg |
JMessage | request message |
onOk |
function | |
onError |
function |
- Source:
query(conn, maintbl, alias, pageInf
, act) → {JMessage}
create a query message.
Parameters:
Name | Type | Description |
---|---|---|
conn |
string | connection id |
maintbl |
string | target table |
alias |
string | target table alias |
pageInf |
Object | page: page index, -1 for no paging size: page size, default 20, -1 for no paging |
act |
Object | user's action for logging {func, cate, cmd, remarks}; |
- Source:
Returns:
the request message
- Type
- JMessage
userReq(conn, port, bodyItem, act) → {JMessage.<UserReq>}
Create a user request JMessage.
Parameters:
Name | Type | Description |
---|---|---|
conn |
string | connection id |
port |
string | |
bodyItem |
Protocol.UserReq | request body, created by like: new jvue.UserReq(conn, tabl). |
act |
Object | action, optional. |
- Source:
Returns:
JMessage
usrAct(funcId, cate, cmd, remarks) → {SessionClient}
Set user's current action to be logged.
Parameters:
Name | Type | Description |
---|---|---|
funcId |
string | curent function id |
cate |
string | category flag |
cmd |
string | |
remarks |
string |
- Source:
Returns:
this
- Type
- SessionClient
usrCmd(cmd) → {SessionClient}
Set user's current action to be logged.
Parameters:
Name | Type | Description |
---|---|---|
cmd |
string | user's command, e.g. 'save' |
- Source:
Returns:
this
- Type
- SessionClient