new api service and logic implemented
This commit is contained in:
168
Events/AllEvents/authentication/auth/auth.py
Normal file
168
Events/AllEvents/authentication/auth/auth.py
Normal file
@@ -0,0 +1,168 @@
|
||||
"""
|
||||
Authentication related API endpoints.
|
||||
"""
|
||||
|
||||
from typing import Union
|
||||
|
||||
from Events.Engine.abstract_class import MethodToEvent
|
||||
from Events.base_request_model import SuccessResponse
|
||||
|
||||
from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
|
||||
from ApiLayers.ApiServices.Token.token_handler import OccupantTokenObject, EmployeeTokenObject
|
||||
|
||||
from .api_events import (
|
||||
authentication_login_super_user_event,
|
||||
authentication_select_company_or_occupant_type_super_user_event,
|
||||
authentication_employee_selection_super_user_event,
|
||||
authentication_occupant_selection_super_user_event,
|
||||
authentication_check_token_event,
|
||||
authentication_refresh_user_info_event,
|
||||
authentication_change_password_event,
|
||||
authentication_create_password_event,
|
||||
authentication_disconnect_user_event,
|
||||
authentication_logout_user_event,
|
||||
authentication_refresher_token_event,
|
||||
authentication_forgot_password_event,
|
||||
authentication_reset_password_event,
|
||||
authentication_download_avatar_event,
|
||||
)
|
||||
|
||||
|
||||
# Type aliases for common types
|
||||
TokenDictType = Union["EmployeeTokenObject", "OccupantTokenObject"]
|
||||
|
||||
|
||||
AuthenticationLoginEventMethods = MethodToEvent(
|
||||
events=[authentication_login_super_user_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/login",
|
||||
method="POST",
|
||||
summary="Login via domain and access key : [email] | [phone]",
|
||||
description="Login to the system via domain, access key : [email] | [phone]",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationSelectEventMethods = MethodToEvent(
|
||||
events=[
|
||||
authentication_select_company_or_occupant_type_super_user_event,
|
||||
authentication_employee_selection_super_user_event,
|
||||
authentication_occupant_selection_super_user_event
|
||||
],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/select",
|
||||
method="POST",
|
||||
summary="Select company or occupant type",
|
||||
description="Select company or occupant type",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationCheckTokenEventMethods = MethodToEvent(
|
||||
events=[authentication_check_token_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/check-token",
|
||||
method="POST",
|
||||
summary="Check if token is valid",
|
||||
description="Check if access token is valid for user",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationRefreshEventMethods = MethodToEvent(
|
||||
events=[authentication_refresh_user_info_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/refresh",
|
||||
method="POST",
|
||||
summary="Refresh user info",
|
||||
description="Refresh user info using access token",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationChangePasswordEventMethods = MethodToEvent(
|
||||
events=[authentication_change_password_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/change-password",
|
||||
method="POST",
|
||||
summary="Change password",
|
||||
description="Change password with access token",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationCreatePasswordEventMethods = MethodToEvent(
|
||||
events=[authentication_create_password_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/create-password",
|
||||
method="POST",
|
||||
summary="Create password",
|
||||
description="Create password with password reset token requested via email",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationDisconnectUserEventMethods = MethodToEvent(
|
||||
events=[authentication_disconnect_user_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/disconnect",
|
||||
method="POST",
|
||||
summary="Disconnect all sessions",
|
||||
description="Disconnect all sessions of user in access token",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationLogoutEventMethods = MethodToEvent(
|
||||
events=[authentication_logout_user_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/logout",
|
||||
method="POST",
|
||||
summary="Logout user",
|
||||
description="Logout only single session of user which domain is provided",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationRefreshTokenEventMethods = MethodToEvent(
|
||||
events=[authentication_refresher_token_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/refresh-token",
|
||||
method="POST",
|
||||
summary="Refresh token",
|
||||
description="Refresh access token with refresher token",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationForgotPasswordEventMethods = MethodToEvent(
|
||||
events=[authentication_forgot_password_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/forgot-password",
|
||||
method="POST",
|
||||
summary="Request password reset",
|
||||
description="Send an email to user for a valid password reset token",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationResetPasswordEventMethods = MethodToEvent(
|
||||
events=[authentication_reset_password_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/reset-password",
|
||||
method="POST",
|
||||
summary="Reset password",
|
||||
description="Reset user password",
|
||||
)
|
||||
|
||||
|
||||
AuthenticationDownloadAvatarEventMethods = MethodToEvent(
|
||||
events=[authentication_download_avatar_event],
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/authentication/download-avatar",
|
||||
method="POST",
|
||||
summary="Download avatar",
|
||||
description="Download avatar icon and profile info of user",
|
||||
)
|
||||
Reference in New Issue
Block a user