mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-26 06:58:27 +00:00
Reduce cyclo complexity
This commit is contained in:
parent
c594bbddb4
commit
28e98d99fc
1 changed files with 12 additions and 2 deletions
|
@ -497,8 +497,7 @@ func Register(
|
|||
// Application services can register users with no auth type, but require
|
||||
// access token. Differentiate from users who are initially hitting register
|
||||
// without an auth type
|
||||
if r.Auth.Type == "" && req.URL.Query().Get("access_token") == "" &&
|
||||
req.Header.Get("Authorization") == "" {
|
||||
if initialUserInteractiveRequest(req, r) {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusUnauthorized,
|
||||
JSON: newUserInteractiveResponse(sessionID,
|
||||
|
@ -782,6 +781,17 @@ func completeRegistration(
|
|||
}
|
||||
}
|
||||
|
||||
// initialUserInteractiveRequest returns true or false based on whether the
|
||||
// request should have User Interactive Authentication Flows returned. This is
|
||||
// the case if a user is requesting registration first without specifying a
|
||||
// registration type. This method also differentiates between application
|
||||
// services and users, as application services can register with no type and an
|
||||
// access token, either included as part of the query parameters or an
|
||||
// Authorization header
|
||||
func initialUserInteractiveRequest(req *http.Request, r registerRequest) bool {
|
||||
return r.Auth.Type == "" && req.URL.Query().Get("access_token") == "" && req.Header.Get("Authorization") == ""
|
||||
}
|
||||
|
||||
// Used for shared secret registration.
|
||||
// Checks if the username, password and isAdmin flag matches the given mac.
|
||||
func isValidMacLogin(
|
||||
|
|
Loading…
Reference in a new issue