auth password forgot and change tested

This commit is contained in:
2024-12-01 15:08:59 +03:00
parent 288a393719
commit a4fd52c28a
17 changed files with 289 additions and 199 deletions

View File

@@ -22,6 +22,7 @@ from api_events.events import (
AuthenticationRefreshEventMethod,
AuthenticationChangePasswordEventMethod,
AuthenticationCreatePasswordEventMethod,
AuthenticationResetPasswordEventMethod,
AuthenticationDisconnectUserEventMethod,
AuthenticationLogoutEventMethod,
AuthenticationRefreshTokenEventMethod,
@@ -55,88 +56,79 @@ def authentication_login_with_domain_and_creds(request: Request, data: Login):
@login_route.get(path="/valid", summary="Check access token is valid")
def authentication_check_token_is_valid(request: Request):
token_dict = parse_token_object_to_dict(request=request)
active_function = getattr(
AuthenticationCheckTokenEventMethod, "authentication_check_token_is_valid"
return AuthenticationCheckTokenEventMethod.authentication_check_token_is_valid(
request=request
)
return active_function(request=request, token_dict=token_dict)
@login_route.get(path="/refresh", summary="Refresh credentials with access token")
def authentication_refresh_user_info(request: Request):
token_dict = parse_token_object_to_dict(request=request)
active_function = getattr(
AuthenticationRefreshEventMethod, "authentication_refresh_user_info"
return AuthenticationRefreshEventMethod.authentication_refresh_user_info(
request=request, token_dict=token_dict
)
return active_function(request=request, token_dict=token_dict)
@login_route.post(path="/change_password", summary="Change password with access token")
def authentication_change_password(request: Request, data: ChangePassword):
token_dict = parse_token_object_to_dict(request=request)
active_function = getattr(
AuthenticationChangePasswordEventMethod, "authentication_change_password"
return AuthenticationChangePasswordEventMethod.authentication_change_password(
data=data, token_dict=token_dict
)
return active_function(data=data, token_dict=token_dict)
@login_route.post(
path="/create_password", summary="Create password with password token"
)
def authentication_create_password(data: CreatePassword):
active_function = getattr(
AuthenticationCreatePasswordEventMethod, "authentication_create_password"
return AuthenticationCreatePasswordEventMethod.authentication_create_password(
data=data
)
@login_route.post(
path="/reset_password", summary="Create password with password token"
)
def authentication_reset_password(data: Forgot):
return AuthenticationResetPasswordEventMethod.authentication_reset_password(
data=data
)
return active_function(data=data)
@login_route.post(path="/disconnect", summary="Disconnect user with access token")
def authentication_disconnect_user(request: Request, data: Logout):
token_dict = parse_token_object_to_dict(request=request)
active_function = getattr(
AuthenticationDisconnectUserEventMethod, "authentication_disconnect_user"
return AuthenticationDisconnectUserEventMethod.authentication_disconnect_user(
data=data, request=request, token_dict=token_dict
)
return active_function(data=data, request=request, token_dict=token_dict)
@login_route.post(path="/logout", summary="Logout user with access token")
def authentication_logout_user(request: Request, data: Logout):
token_dict = parse_token_object_to_dict(request=request)
active_function = getattr(
AuthenticationLogoutEventMethod, "authentication_logout_user"
return AuthenticationLogoutEventMethod.authentication_logout_user(
data=data, token_dict=token_dict
)
return active_function(data=data, request=request, token_dict=token_dict)
@login_route.post(path="/refresher", summary="Refresh token with refresh token")
def authentication_refresher_token(request: Request, data: Remember):
token_dict = parse_token_object_to_dict(request=request)
active_function = getattr(
AuthenticationRefreshTokenEventMethod, "authentication_refresher_token"
return AuthenticationRefreshTokenEventMethod.authentication_refresher_token(
data=data, request=request, token_dict=token_dict
)
return active_function(data=data, request=request, token_dict=token_dict)
@login_route.post(path="/forgot", summary="Forgot password with email or phone number")
def authentication_forgot_password(request: Request, data: Forgot):
token_dict = parse_token_object_to_dict(request=request)
active_function = getattr(
AuthenticationForgotPasswordEventMethod, "authentication_forgot_password"
return AuthenticationForgotPasswordEventMethod.authentication_forgot_password(
data=data, request=request, token_dict=token_dict
)
return active_function(data=data, request=request, token_dict=token_dict)
@login_route.post(path="/avatar", summary="Get link of avatar with credentials")
def authentication_download_avatar(request: Request, data: Forgot):
token_dict = parse_token_object_to_dict(request=request)
active_function = getattr(
AuthenticationDownloadAvatarEventMethod, "authentication_download_avatar"
return AuthenticationDownloadAvatarEventMethod.authentication_download_avatar(
data=data, request=request, token_dict=token_dict
)
return active_function(data=data, request=request, token_dict=token_dict)