MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / checkAuthorizationLevel

Function checkAuthorizationLevel

src/authentication.go:135–169  ·  view source on GitHub ↗
(token, level string)

Source from the content-addressed store, hash-verified

133}
134
135func checkAuthorizationLevel(token, level string) (err error) {
136
137 var authenticationErr = func(err error) {
138 if err != nil {
139 return
140 }
141 }
142
143 userID, err := authentication.GetUserID(token)
144 authenticationErr(err)
145
146 userData, err := authentication.ReadUserData(userID)
147 authenticationErr(err)
148
149 if len(userData) > 0 {
150
151 if v, ok := userData[level].(bool); ok {
152
153 if v == false {
154 err = errors.New("No authorization")
155 }
156
157 } else {
158 userData[level] = false
159 err = authentication.WriteUserData(userID, userData)
160 err = errors.New("No authorization")
161 }
162
163 } else {
164 err = authentication.WriteUserData(userID, userData)
165 err = errors.New("No authorization")
166 }
167
168 return
169}

Callers 4

basicAuthFunction · 0.85
urlAuthFunction · 0.85
WebFunction · 0.85
APIFunction · 0.85

Calls 3

GetUserIDFunction · 0.92
ReadUserDataFunction · 0.92
WriteUserDataFunction · 0.92

Tested by

no test coverage detected