| 1 |
package state |
| 2 |
|
| 3 |
const ( |
| 4 |
SessionNoState = "0" |
| 5 |
SessionStateEmpty = "1" |
| 6 |
SessionStateInitial = "2" |
| 7 |
SessionStateAuthenticated = "3" |
| 8 |
SessionStateExpired = "4" |
| 9 |
SessionStateInvalid = "5" |
| 10 |
SessionStateAuthenticatedEmptyUser = "6" |
| 11 |
SessionStateExpiredEmptyUser = "7" |
| 12 |
) |
| 13 |
|
| 14 |
//nolint:gochecknoglobals |
| 15 |
var sessionStateMap = map[string]string{ |
| 16 |
"Empty": SessionStateEmpty, |
| 17 |
"Initial": SessionStateInitial, |
| 18 |
"Authenticated": SessionStateAuthenticated, |
| 19 |
"Expired": SessionStateExpired, |
| 20 |
"Invalid": SessionStateInvalid, |
| 21 |
"AuthenticatedEmptyUser": SessionStateAuthenticatedEmptyUser, |
| 22 |
"ExpiredEmptyUser": SessionStateExpiredEmptyUser, |
| 23 |
} |
| 24 |
|
| 25 |
//nolint:gochecknoglobals |
| 26 |
var sessionStateReverseMap = map[string]string{ |
| 27 |
SessionStateEmpty: "Empty", |
| 28 |
SessionStateInitial: "Initial", |
| 29 |
SessionStateAuthenticated: "Authenticated", |
| 30 |
SessionStateExpired: "Expired", |
| 31 |
SessionStateInvalid: "Invalid", |
| 32 |
SessionStateAuthenticatedEmptyUser: "AuthenticatedEmptyUser", |
| 33 |
SessionStateExpiredEmptyUser: "ExpiredEmptyUser", |
| 34 |
} |
| 35 |
|
| 36 |
// decodeSessionState returns the string representation of the session state. |
| 37 |
func decodeSessionState(s string) string { |
| 38 |
if v, ok := sessionStateReverseMap[s]; ok { |
| 39 |
return v |
| 40 |
} |
| 41 |
|
| 42 |
return "" |
| 43 |
} |
| 44 |
|
| 45 |
// encodeSessionState returns the compact representation of the session state. |
| 46 |
func encodeSessionState(s string) string { |
| 47 |
if v, ok := sessionStateMap[s]; ok { |
| 48 |
return v |
| 49 |
} |
| 50 |
|
| 51 |
return SessionNoState |
| 52 |
} |