diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..7947b37
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/wag-managment-api-service-version-5.iml b/.idea/wag-managment-api-service-version-5.iml
index 5fdd65b..67c6042 100644
--- a/.idea/wag-managment-api-service-version-5.iml
+++ b/.idea/wag-managment-api-service-version-5.iml
@@ -2,7 +2,7 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 48fba99..f7a6bc1 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,111 +5,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -119,22 +25,22 @@
-
+ {
+ "associatedIndex": 4
+}
- {
+ "keyToString": {
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "git-widget-placeholder": "development",
+ "last_opened_file_path": "/home/berkay/git-gitea-evyos/wag-managment-api-service-version-5"
}
-}]]>
+}
diff --git a/ApiLayers/ApiServices/Login/user_login_handler.py b/ApiLayers/ApiServices/Login/user_login_handler.py
index 4ca7889..fbbc219 100644
--- a/ApiLayers/ApiServices/Login/user_login_handler.py
+++ b/ApiLayers/ApiServices/Login/user_login_handler.py
@@ -1,12 +1,9 @@
-from typing import Any, ClassVar, Dict
-from sqlalchemy import or_
+from typing import Any, Dict
-from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
from ApiLayers.ErrorHandlers import HTTPExceptionApi
from ApiLayers.ApiValidations.Request.authentication import Login
from ApiLayers.ApiLibrary.token.password_module import PasswordModule
-from ApiLayers.ApiServices.Token.token_handler import TokenService
-from ApiLayers.Schemas import Users
+from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
class UserLoginModule:
@@ -15,15 +12,17 @@ class UserLoginModule:
self.request = request
@staticmethod
- async def check_user_exists(access_key) -> ClassVar[Users]:
+ def check_user_exists(access_key: str):
+ from ApiLayers.Schemas import Users
+
"""Check if user exists."""
db_session = Users.new_session()
if "@" in access_key:
- found_user = Users.filter_one(
+ found_user: Users = Users.filter_one(
Users.email == access_key.lower(), db=db_session
).data
else:
- found_user = Users.filter_one(
+ found_user: Users = Users.filter_one(
Users.phone_number == access_key.replace(" ", ""), db=db_session
).data
if not found_user:
@@ -35,15 +34,13 @@ class UserLoginModule:
)
return found_user
- async def login_user_via_credentials(self, access_data: "Login") -> Dict[str, Any]:
+ def login_user_via_credentials(self, access_data: "Login") -> Dict[str, Any]:
+ from ApiLayers.ApiServices.Token.token_handler import TokenService
+ from ApiLayers.Schemas import Users
+
"""Login user via credentials."""
# Get the actual data from the BaseRequestModel if needed
- if hasattr(access_data, "data"):
- access_data = access_data.data
-
- found_user: Users = await self.check_user_exists(
- access_key=access_data.access_key
- )
+ found_user: Users = self.check_user_exists(access_key=access_data.access_key)
if len(found_user.hash_password) < 5:
raise HTTPExceptionApi(
error_code="HTTP_400_BAD_REQUEST",
@@ -51,7 +48,6 @@ class UserLoginModule:
loc=get_line_number_for_error(),
sys_msg="Invalid password create a password to user first",
)
-
if PasswordModule.check_password(
domain=access_data.domain,
id_=found_user.uu_id,
diff --git a/ApiLayers/ApiServices/Token/token_handler.py b/ApiLayers/ApiServices/Token/token_handler.py
index 5b559e8..96913fc 100644
--- a/ApiLayers/ApiServices/Token/token_handler.py
+++ b/ApiLayers/ApiServices/Token/token_handler.py
@@ -126,7 +126,7 @@ class TokenService:
request=dict(request.headers),
available_occupants=occupants_selection_dict,
timezone=user.local_timezone or "GMT+0",
- lang=user.lang or "tr",
+ lang="tr",
).model_dump()
if access_token := cls.set_object_to_redis(user, model_value):
return {
@@ -229,6 +229,7 @@ class TokenService:
}
)
person = People.filter_one(People.id == user.person_id, db=db_session).data
+
model_value = EmployeeTokenObject(
domain=domain,
user_type=UserType.employee.value,
@@ -243,7 +244,7 @@ class TokenService:
duty_uu_id_list=duty_uu_id_list,
duty_id_list=duty_id_list,
timezone=user.local_timezone or "GMT+0",
- lang=user.lang or "tr",
+ lang="tr",
).model_dump()
if access_token := cls.set_object_to_redis(user, model_value):
return {
diff --git a/ApiLayers/Schemas/identity/identity.py b/ApiLayers/Schemas/identity/identity.py
index 133ebe1..51a82ec 100644
--- a/ApiLayers/Schemas/identity/identity.py
+++ b/ApiLayers/Schemas/identity/identity.py
@@ -20,6 +20,7 @@ from ApiLayers.ApiLibrary.date_time_actions.date_functions import system_arrow
from ApiLayers.ApiLibrary.extensions.select import SelectAction, SelectActionWithEmployee
from ApiLayers.AllConfigs.Token.config import Auth
+from ApiLayers.ApiServices.Login.user_login_handler import UserLoginModule
from Services.PostgresDb import CrudCollection
from config import ApiStatic
@@ -64,10 +65,6 @@ class UsersTokens(CrudCollection):
# users = relationship("Users", back_populates="tokens", foreign_keys=[user_id])
-class UserLoginModule:
- pass
-
-
class Users(CrudCollection, UserLoginModule, SelectAction):
"""
Application User frame to connect to API with assigned token-based HTTP connection
@@ -369,6 +366,14 @@ class People(CrudCollection, SelectAction):
tax_no: Mapped[str] = mapped_column(
String, server_default="", comment="Tax number of the person"
)
+ # Receive at Create person
+ # language = mapped_column(
+ # String, comment="Language code of the person"
+ # )
+ # currency = mapped_column(
+ # String, comment="Currency code of the person"
+ # )
+
# ENCRYPT DATA
user = relationship(
"Users", back_populates="person", foreign_keys="Users.person_id"
diff --git a/Events/AllEvents/authentication/auth/api_events.py b/Events/AllEvents/authentication/auth/api_events.py
index de56d08..b8c1333 100644
--- a/Events/AllEvents/authentication/auth/api_events.py
+++ b/Events/AllEvents/authentication/auth/api_events.py
@@ -26,6 +26,7 @@ from .function_handlers import (
)
+
# Auth Login
authentication_login_super_user_event = Event(
name="authentication_login_super_user_event",
diff --git a/Events/AllEvents/authentication/auth/auth.py b/Events/AllEvents/authentication/auth/auth.py
index 5ec1a05..39da5ea 100644
--- a/Events/AllEvents/authentication/auth/auth.py
+++ b/Events/AllEvents/authentication/auth/auth.py
@@ -46,15 +46,16 @@ AuthenticationLoginEventMethods = MethodToEvent(
description="Login to the system via domain, access key : [email] | [phone]",
)
-def authentication_login_with_domain_and_creds(
+def authentication_login_with_domain_and_creds_endpoint(
request: Request,
data: EndpointBaseRequestModel,
) -> Dict[str, Any]:
- function = AuthenticationLoginEventMethods.retrieve_event(event_function_code=f"{authentication_login_super_user_event.key}")
- return function.endpoint_callable(request=request, data=data)
+ event_2_catch = AuthenticationLoginEventMethods.retrieve_event(event_function_code=f"{authentication_login_super_user_event.key}")
+ data = event_2_catch.REQUEST_VALIDATOR(**data.data)
+ return event_2_catch.endpoint_callable(request=request, data=data)
-AuthenticationLoginEventMethods.endpoint_callable = authentication_login_with_domain_and_creds
+AuthenticationLoginEventMethods.endpoint_callable = authentication_login_with_domain_and_creds_endpoint
AuthenticationSelectEventMethods = MethodToEvent(
name="AuthenticationSelectEventMethods",
diff --git a/Events/AllEvents/authentication/auth/models.py b/Events/AllEvents/authentication/auth/models.py
index 41e0a34..63e5757 100644
--- a/Events/AllEvents/authentication/auth/models.py
+++ b/Events/AllEvents/authentication/auth/models.py
@@ -1,7 +1,9 @@
from pydantic import BaseModel
+from ApiLayers.ApiValidations.Request import (
+ Login,
+)
-
-class LoginSuperUserRequestModel(BaseModel):
+class LoginSuperUserRequestModel(Login):
pass
diff --git a/Services/PostgresDb/Models/crud_alchemy.py b/Services/PostgresDb/Models/crud_alchemy.py
index 911278a..bb0976b 100644
--- a/Services/PostgresDb/Models/crud_alchemy.py
+++ b/Services/PostgresDb/Models/crud_alchemy.py
@@ -209,7 +209,7 @@ class CrudActions(SystemFields):
return return_dict
-class CRUDModel(BaseAlchemyModel, CrudActions):
+class CRUDModel(CrudActions):
__abstract__ = True
diff --git a/Services/PostgresDb/Models/filter_functions.py b/Services/PostgresDb/Models/filter_functions.py
index 6ad6654..2c6e70f 100644
--- a/Services/PostgresDb/Models/filter_functions.py
+++ b/Services/PostgresDb/Models/filter_functions.py
@@ -10,15 +10,13 @@ from typing import Any, TypeVar, Type
from sqlalchemy.orm import Query, Session
from sqlalchemy.sql.elements import BinaryExpression
-from sqlalchemy_mixins.smartquery import SmartQueryMixin
from Services.PostgresDb.Models.response import PostgresResponse
-from Services.PostgresDb.Models.core_alchemy import BaseAlchemyModel
from ApiLayers.ApiLibrary import system_arrow
-T = TypeVar("T", bound="FilterAttributes")
+T = TypeVar("T", bound="QueryModel")
class ArgumentModel:
@@ -63,7 +61,7 @@ class ArgumentModel:
return arg
-class QueryModel(ArgumentModel, BaseAlchemyModel, SmartQueryMixin):
+class QueryModel(ArgumentModel):
pre_query = None
__abstract__ = True
@@ -127,8 +125,8 @@ class QueryModel(ArgumentModel, BaseAlchemyModel, SmartQueryMixin):
args = cls.get_active_and_confirmed_query_arg(args)
if not expired:
args = cls.get_not_expired_query_arg(args)
- query = cls._query(db).filter(*args)
- return PostgresResponse(pre_query=cls._query(db), query=query, is_array=False)
+ query = cls._query(db=db).filter(*args)
+ return PostgresResponse(pre_query=cls._query(db=db), query=query, is_array=False)
@classmethod
def filter_all_system(
diff --git a/Services/PostgresDb/Models/mixin.py b/Services/PostgresDb/Models/mixin.py
index 1187b3d..b91d7d1 100644
--- a/Services/PostgresDb/Models/mixin.py
+++ b/Services/PostgresDb/Models/mixin.py
@@ -12,18 +12,21 @@ from sqlalchemy import (
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy_mixins.serialize import SerializeMixin
from sqlalchemy_mixins.repr import ReprMixin
+from sqlalchemy_mixins.smartquery import SmartQueryMixin
+from Services.PostgresDb.Models.core_alchemy import BaseAlchemyModel
from Services.PostgresDb.Models.crud_alchemy import CRUDModel
from Services.PostgresDb.Models.filter_functions import QueryModel
+from Services.PostgresDb.database import Base
-class BasicMixin(CRUDModel, QueryModel):
+class BasicMixin(Base, BaseAlchemyModel):
__abstract__ = True
__repr__ = ReprMixin.__repr__
-class CrudMixin(BasicMixin, SerializeMixin, ReprMixin):
+class CrudMixin(BasicMixin, CRUDModel, SerializeMixin, ReprMixin, SmartQueryMixin, QueryModel ):
"""
Base mixin providing CRUD operations and common fields for PostgreSQL models.