replace tmp variable name, doc improvements
This commit is contained in:
parent
685ddeff00
commit
cc7fc5ab91
3 changed files with 24 additions and 13 deletions
|
@ -9,8 +9,10 @@ from areas.apps.models import App, AppRole
|
||||||
from areas.roles.role_service import RoleService
|
from areas.roles.role_service import RoleService
|
||||||
from helpers import KratosApi
|
from helpers import KratosApi
|
||||||
|
|
||||||
tmp = ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True)
|
kratos_admin_api_configuration = \
|
||||||
KRATOS_ADMIN = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp))
|
ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True)
|
||||||
|
KRATOS_ADMIN = \
|
||||||
|
kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_admin_api_configuration))
|
||||||
|
|
||||||
class UserService:
|
class UserService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -51,18 +53,19 @@ class UserService:
|
||||||
db.session.add(app_role)
|
db.session.add(app_role)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
UserService.__start_user_recovery_flow(data["email"])
|
UserService.__start_recovery_flow(data["email"])
|
||||||
|
|
||||||
return UserService.get_user(res["id"])
|
return UserService.get_user(res["id"])
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __start_user_recovery_flow(email):
|
def __start_recovery_flow(email):
|
||||||
"""
|
"""
|
||||||
Start a Kratos recovery flow for the user's email address.
|
Start a Kratos recovery flow for the user's email address.
|
||||||
|
|
||||||
This sends out an email to the user that explains to them how they can
|
This sends out an email to the user that explains to them how they can
|
||||||
set their password.
|
set their password. Make sure the user exists inside Kratos before you
|
||||||
|
use this function.
|
||||||
|
|
||||||
:param email: Email to send recovery link to
|
:param email: Email to send recovery link to
|
||||||
:type email: str
|
:type email: str
|
||||||
|
|
|
@ -27,11 +27,15 @@ HYDRA = hydra_client.HydraAdmin(HYDRA_ADMIN_URL)
|
||||||
# Kratos has an admin and public end-point. We create an API for them
|
# Kratos has an admin and public end-point. We create an API for them
|
||||||
# both. The kratos implementation has bugs, which forces us to set
|
# both. The kratos implementation has bugs, which forces us to set
|
||||||
# the discard_unknown_keys to True.
|
# the discard_unknown_keys to True.
|
||||||
tmp = ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True)
|
kratos_admin_api_configuration = \
|
||||||
KRATOS_ADMIN = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp))
|
ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True)
|
||||||
|
KRATOS_ADMIN = \
|
||||||
|
kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_admin_api_configuration))
|
||||||
|
|
||||||
tmp = ory_kratos_client.Configuration(host=KRATOS_PUBLIC_URL, discard_unknown_keys=True)
|
kratos_public_api_configuration = \
|
||||||
KRATOS_PUBLIC = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp))
|
ory_kratos_client.Configuration(host=KRATOS_PUBLIC_URL, discard_unknown_keys=True)
|
||||||
|
KRATOS_PUBLIC = \
|
||||||
|
kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_public_api_configuration))
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# CLI INTERFACE #
|
# CLI INTERFACE #
|
||||||
|
|
|
@ -31,11 +31,15 @@ HYDRA = hydra_client.HydraAdmin(HYDRA_ADMIN_URL)
|
||||||
# Kratos has an admin and public end-point. We create an API for them
|
# Kratos has an admin and public end-point. We create an API for them
|
||||||
# both. The kratos implementation has bugs, which forces us to set
|
# both. The kratos implementation has bugs, which forces us to set
|
||||||
# the discard_unknown_keys to True.
|
# the discard_unknown_keys to True.
|
||||||
tmp = ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True)
|
kratos_admin_api_configuration = \
|
||||||
KRATOS_ADMIN = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp))
|
ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True)
|
||||||
|
KRATOS_ADMIN = \
|
||||||
|
kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_admin_api_configuration))
|
||||||
|
|
||||||
tmp = ory_kratos_client.Configuration(host=KRATOS_PUBLIC_URL, discard_unknown_keys=True)
|
kratos_public_api_configuration = \
|
||||||
KRATOS_PUBLIC = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp))
|
ory_kratos_client.Configuration(host=KRATOS_PUBLIC_URL, discard_unknown_keys=True)
|
||||||
|
KRATOS_PUBLIC = \
|
||||||
|
kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_public_api_configuration))
|
||||||
ADMIN_ROLE_ID = 1
|
ADMIN_ROLE_ID = 1
|
||||||
NO_ACCESS_ROLE_ID = 3
|
NO_ACCESS_ROLE_ID = 3
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue