MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / registration_view

Function registration_view

web/pgadmin/authenticate/mfa/views.py:311–386  ·  view source on GitHub ↗

A url end-point to register/deregister an authentication method. It supports two HTTP methods: * GET : Generate a view listing all the supported list with 'Setup', or 'Delete' buttons. If user has registered for the auth method, it will render a 'Delete' button

()

Source from the content-addressed store, hash-verified

309
310@pgCSRFProtect.exempt
311def registration_view() -> Response:
312 """
313 A url end-point to register/deregister an authentication method.
314
315 It supports two HTTP methods:
316 * GET : Generate a view listing all the supported list with 'Setup',
317 or 'Delete' buttons. If user has registered for the auth method, it
318 will render a 'Delete' button next to it, and 'Setup' button
319 otherwise.
320 * POST: This handles multiple scenarios on the registration page:
321 1. Clicked on the 'Delete' button, it will deregister the user for
322 the specific auth method, and render the view same as for the
323 'GET' method.
324 2. Clicked on the 'Setup' button, it will render the registration
325 view for the authentication method.
326 3. Clicked 'Continue' button, redirect it to the url specified by
327 'next' url.
328 4. Clicking on 'Cancel' button on the Auth method specific view
329 will render the view by 'GET' HTTP method.
330 5. A registration method can run like a wizard, and generate
331 different views based on the request data.
332
333 Returns:
334 Response: A response object with list of auth methods, a registration
335 view, or redirect to 'next' url
336 """
337 next_url = request.args.get("next", None)
338 if not current_user.is_authenticated:
339 flash(_("Session expired. Please refresh the page."),
340 MessageType.ERROR)
341 return Response(render_template(
342 'mfa/register.html', _=_,
343 mfa_list=[], mfa_view=None, next_url=next_url,
344 error_message=None,
345 ))
346
347 mfa_auths = mfa_suppored_methods()
348 mfa_list = list()
349
350 if request.method == 'POST':
351 next_url, response, mfa_auths = \
352 __handle_registration_view_for_post_method(next_url, mfa_auths)
353
354 if response is not None:
355 return response
356
357 if next_url is None:
358 next_url = url_for(_INDEX_URL)
359
360 error_message = None
361 found_one_mfa = False
362
363 for key in mfa_auths:
364 mfa = mfa_auths[key]['mfa']
365 mfa = mfa.to_dict()
366 mfa["registered"] = mfa_auths[key]["registered"]
367 mfa_list.append(mfa)
368 found_one_mfa = found_one_mfa or mfa["registered"]

Callers

nothing calls this directly

Calls 7

mfa_suppored_methodsFunction · 0.85
is_mfa_enabledFunction · 0.85
appendMethod · 0.80
getMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected