MCPcopy
hub / github.com/dgraph-io/dgraph / validateLoginRequest

Function validateLoginRequest

edgraph/access.go:222–239  ·  view source on GitHub ↗

validateLoginRequest validates that the login request has either the refresh token or the pair

(request *api.LoginRequest)

Source from the content-addressed store, hash-verified

220// validateLoginRequest validates that the login request has either the refresh token or the
221// <user id, password> pair
222func validateLoginRequest(request *api.LoginRequest) error {
223 if request == nil {
224 return errors.Errorf("the request should not be nil")
225 }
226 // we will use the refresh token for authentication if it's set
227 if len(request.RefreshToken) > 0 {
228 return nil
229 }
230
231 // otherwise make sure both userid and password are set
232 if len(request.Userid) == 0 {
233 return errors.Errorf("the userid should not be empty")
234 }
235 if len(request.Password) == 0 {
236 return errors.Errorf("the password should not be empty")
237 }
238 return nil
239}
240
241// getAccessJwt constructs an access jwt with the given user id, groupIds, namespace
242// and expiration TTL specified by worker.Config.AccessJwtTtl

Callers 1

authenticateLoginMethod · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected