MCPcopy Create free account
hub / github.com/daodst/chat / checkAndCompleteFlow

Function checkAndCompleteFlow

clientapi/routing/register.go:828–851  ·  view source on GitHub ↗

checkAndCompleteFlow checks if a given registration flow is completed given a set of allowed flows. If so, registration is completed, otherwise a response with

(
	flow []authtypes.LoginType,
	req *http.Request,
	r registerRequest,
	sessionID string,
	cfg *config.ClientAPI,
	userAPI userapi.ClientUserAPI,
)

Source from the content-addressed store, hash-verified

826// a set of allowed flows. If so, registration is completed, otherwise a
827// response with
828func checkAndCompleteFlow(
829 flow []authtypes.LoginType,
830 req *http.Request,
831 r registerRequest,
832 sessionID string,
833 cfg *config.ClientAPI,
834 userAPI userapi.ClientUserAPI,
835) util.JSONResponse {
836 if checkFlowCompleted(flow, cfg.Derived.Registration.Flows) {
837 // This flow was completed, registration can continue
838 return completeRegistration(
839 req.Context(), userAPI, r.Username, r.Password, "", req.RemoteAddr, req.UserAgent(), sessionID,
840 r.InhibitLogin, r.InitialDisplayName, r.DeviceID, userapi.AccountTypeUser,
841 )
842 }
843 sessions.addParams(sessionID, r)
844 // There are still more stages to complete.
845 // Return the flows and those that have been completed.
846 return util.JSONResponse{
847 Code: http.StatusUnauthorized,
848 JSON: newUserInteractiveResponse(sessionID,
849 cfg.Derived.Registration.Flows, cfg.Derived.Registration.Params),
850 }
851}
852
853// completeRegistration runs some rudimentary checks against the submitted
854// input, then if successful creates an account and a newly associated device

Callers 1

handleRegistrationFlowFunction · 0.85

Calls 5

checkFlowCompletedFunction · 0.85
completeRegistrationFunction · 0.85
ContextMethod · 0.80
addParamsMethod · 0.80

Tested by

no test coverage detected