xn-auth 0.0.2__tar.gz → 0.0.3.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ repos:
14
14
  - id: build
15
15
  name: build
16
16
  ### build & upload package only for "main" branch push
17
- entry: bash -c 'echo $PRE_COMMIT_LOCAL_BRANCH | grep /master && make build || echo 0'
17
+ entry: bash -c 'echo $PRE_COMMIT_LOCAL_BRANCH | grep /main && make build || echo 0'
18
18
  language: system
19
19
  pass_filenames: false
20
20
  verbose: true
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xn-auth
3
- Version: 0.0.2
3
+ Version: 0.0.3.dev1
4
4
  Summary: Auth adapter for XN-Api framework
5
5
  Author-email: Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -0,0 +1,24 @@
1
+ from tortoise.fields import CharField
2
+ from x_model import User as BaseUser
3
+
4
+
5
+ class User(BaseUser):
6
+ from pwdlib import PasswordHash
7
+
8
+ __cc = PasswordHash.recommended()
9
+
10
+ password: str | None = CharField(60, null=True)
11
+
12
+ def pwd_vrf(self, pwd: str) -> bool:
13
+ return self.__cc.verify(pwd, self.password)
14
+
15
+ @classmethod
16
+ async def create(cls, using_db=None, **kwargs) -> BaseUser:
17
+ user: User = await super().create(using_db, **kwargs)
18
+ if pwd := kwargs.get("password"):
19
+ await user.set_pwd(pwd)
20
+ return user
21
+
22
+ async def set_pwd(self, pwd: str = password) -> None:
23
+ self.password = self.__cc.hash(pwd)
24
+ await self.save()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xn-auth
3
- Version: 0.0.2
3
+ Version: 0.0.3.dev1
4
4
  Summary: Auth adapter for XN-Api framework
5
5
  Author-email: Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -5,6 +5,7 @@ README.md
5
5
  makefile
6
6
  pyproject.toml
7
7
  x_auth/__init__.py
8
+ x_auth/models.py
8
9
  xn_auth.egg-info/PKG-INFO
9
10
  xn_auth.egg-info/SOURCES.txt
10
11
  xn_auth.egg-info/dependency_links.txt
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes