Coverage for /home/runner/work/viur-core/viur-core/viur/src/viur/core/render/json/user.py: 0%
32 statements
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-16 22:16 +0000
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-16 22:16 +0000
1import json
2from viur.core.modules.user import UserSecondFactorAuthentication
3from . import default as DefaultRender
4from .default import CustomJsonEncoder
7class UserRender(DefaultRender): # Render user-data to json
9 def login(self, skel, **kwargs):
10 if kwargs.get("loginFailed", False):
11 return json.dumps("FAILURE")
12 return self.edit(skel, **kwargs)
14 def loginChoices(self, authMethods, **kwargs):
15 return json.dumps(list(set([x[0] for x in authMethods])), cls=CustomJsonEncoder)
17 def loginSucceeded(self, msg="OKAY", **kwargs):
18 return json.dumps(msg)
20 def logoutSuccess(self, **kwargs):
21 return json.dumps("OKAY")
23 def verifySuccess(self, skel, **kwargs):
24 return json.dumps("OKAY")
26 def verifyFailed(self, **kwargs):
27 return json.dumps("FAILED")
29 def passwdRecoverInfo(self, msg, skel=None, tpl=None, **kwargs):
30 if skel:
31 return self.edit(skel, **kwargs)
33 return json.dumps(msg)
35 def passwdRecover(self, *args, **kwargs):
36 return self.edit(*args, **kwargs)
38 def second_factor_add(self, otp_uri=None, *args, **kwargs):
39 return json.dumps({"otp_uri": otp_uri})
41 def second_factor_add_success(self, *args, **kwargs):
42 return json.dumps("OKAY")
44 def second_factor_choice(
45 self,
46 second_factors: list[UserSecondFactorAuthentication] | tuple[UserSecondFactorAuthentication] | None = None,
47 *args, **kwargs
48 ):
49 second_factors = [{"name": second_factor.NAME, "start_url": second_factor.start_url}
50 for second_factor in second_factors]
51 return json.dumps(second_factors, cls=CustomJsonEncoder)