MCPcopy Create free account
hub / github.com/MG-RAST/Shock / SetMongoInfo

Method SetMongoInfo

shock-server/user/user.go:97–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95}
96
97func (u *User) SetMongoInfo() (err error) {
98 if uu, admin, err := dbGetInfo(u.Username); err == nil {
99 u.Uuid = uu
100 u.Admin = admin
101 return nil
102 } else {
103 // this is a new user
104 u.Uuid = uuid.New()
105 // check if user is on admin list, if so set as true
106 for _, v := range conf.AdminUsers {
107 if v == u.Username {
108 u.Admin = true
109 break
110 }
111 }
112 if err := u.Save(); err != nil {
113 return err
114 }
115 }
116 return
117}
118
119func dbGetInfo(username string) (uuid string, admin bool, err error) {
120 session := db.Connection.Session.Copy()

Callers 4

ReadManyMethod · 0.95
parseAclRequestTypedFunction · 0.95
authTokenFunction · 0.80
fetchProfileFunction · 0.80

Calls 2

SaveMethod · 0.95
dbGetInfoFunction · 0.85

Tested by

no test coverage detected