This repository has been archived by the owner on Nov 5, 2019. It is now read-only.
/
actions_user.go
137 lines (121 loc) · 3.57 KB
/
actions_user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package main
import (
"encoding/json"
)
// TODO - abandoned session-over-websockets stuff for now b/c
// to get a session we're currently using cookies, which are far easier
// as ajax calls
type CreateUserAct struct {
ReqAction
Username string
Email string
Password string
}
func (CreateUserAct) Type() string { return "SESSION_SIGNUP_REQUEST" }
func (CreateUserAct) SuccessType() string { return "SESSION_SIGNUP_SUCCESS" }
func (CreateUserAct) FailureType() string { return "SESSION_SIGNUP_FAILURE" }
func (CreateUserAct) Parse(reqId string, data json.RawMessage) ClientRequestAction {
a := &CreateUserAct{}
a.RequestId = reqId
a.err = json.Unmarshal(data, a)
return a
}
func (s *CreateUserAct) Exec() (res *ClientResponse) {
return &ClientResponse{
Type: s.SuccessType(),
RequestId: s.RequestId,
Schema: "SEARCH_RESULT_ARRAY",
// Data: results,
}
}
type SessionLoginAct struct {
ReqAction
Username string
Password string
}
func (SessionLoginAct) Type() string { return "SESSION_LOGIN_REQUEST" }
func (SessionLoginAct) SuccessType() string { return "SESSION_LOGIN_SUCCESS" }
func (SessionLoginAct) FailureType() string { return "SESSION_LOGIN_FAILURE" }
func (SessionLoginAct) Parse(reqId string, data json.RawMessage) ClientRequestAction {
a := &SessionLoginAct{}
a.RequestId = reqId
a.err = json.Unmarshal(data, a)
return a
}
func (s *SessionLoginAct) Exec() (res *ClientResponse) {
return &ClientResponse{
Type: s.SuccessType(),
RequestId: s.RequestId,
Schema: "USER",
// Data: results,
}
}
type SessionLogoutAct struct {
ReqAction
Query string
Page int
PageSize int
}
func (SessionLogoutAct) Type() string { return "SESSION_LOGOUT_REQUEST" }
func (SessionLogoutAct) SuccessType() string { return "SESSION_LOGOUT_SUCCESS" }
func (SessionLogoutAct) FailureType() string { return "SESSION_LOGOUT_FAILURE" }
func (SessionLogoutAct) Parse(reqId string, data json.RawMessage) ClientRequestAction {
a := &SessionLogoutAct{}
a.RequestId = reqId
a.err = json.Unmarshal(data, a)
return a
}
func (s *SessionLogoutAct) Exec() (res *ClientResponse) {
return &ClientResponse{
Type: s.SuccessType(),
RequestId: s.RequestId,
Schema: "USER",
// Data: results,
}
}
type SessionKeysAct struct {
ReqAction
Query string
Page int
PageSize int
}
func (SessionKeysAct) Type() string { return "SESSION_KEYS_REQUEST" }
func (SessionKeysAct) SuccessType() string { return "SESSION_KEYS_SUCCESS" }
func (SessionKeysAct) FailureType() string { return "SESSION_KEYS_FAILURE" }
func (SessionKeysAct) Parse(reqId string, data json.RawMessage) ClientRequestAction {
a := &SessionKeysAct{}
a.RequestId = reqId
a.err = json.Unmarshal(data, a)
return a
}
func (s *SessionKeysAct) Exec() (res *ClientResponse) {
return &ClientResponse{
Type: s.SuccessType(),
RequestId: s.RequestId,
// Schema: "KEY_ARRAY",
// Data: results,
}
}
type SaveUserAct struct {
ReqAction
Query string
Page int
PageSize int
}
func (SaveUserAct) Type() string { return "SAVE_SESSION_USER_REQUEST" }
func (SaveUserAct) SuccessType() string { return "SAVE_SESSION_USER_SUCCESS" }
func (SaveUserAct) FailureType() string { return "SAVE_SESSION_USER_FAILURE" }
func (SaveUserAct) Parse(reqId string, data json.RawMessage) ClientRequestAction {
a := &SaveUserAct{}
a.RequestId = reqId
a.err = json.Unmarshal(data, a)
return a
}
func (s *SaveUserAct) Exec() (res *ClientResponse) {
return &ClientResponse{
Type: s.SuccessType(),
RequestId: s.RequestId,
Schema: "USER",
// Data: results,
}
}