-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
handle_state.go
46 lines (39 loc) · 901 Bytes
/
handle_state.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
package server
import (
"os"
"runtime"
"github.com/ecnepsnai/web"
)
func (h *handle) State(request web.Request) (interface{}, *web.Error) {
type runtimeType struct {
ServerFQDN string
Version string
Config string
}
type stateType struct {
Runtime runtimeType
User *User
Enums map[string]interface{}
Warnings []string
Options *OttoOptions
}
hostname, _ := os.Hostname()
user := request.UserData.(*Session).User()
s := stateType{
Runtime: runtimeType{
ServerFQDN: hostname,
Version: ServerVersion,
Config: runtime.GOOS + "_" + runtime.GOARCH,
},
User: user,
Enums: AllEnums,
Warnings: []string{},
Options: Options,
}
if user.Username == defaultUser.Username {
if ShadowStore.Compare(user.Username, []byte(defaultUser.Password)) {
s.Warnings = append(s.Warnings, "default_user_password")
}
}
return s, nil
}