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, )
| 826 | // a set of allowed flows. If so, registration is completed, otherwise a |
| 827 | // response with |
| 828 | func 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 |
no test coverage detected