|
19 | 19 |
|
20 | 20 | from ..utils.requests import Requests as requests
|
21 | 21 |
|
| 22 | +class Verificator: |
| 23 | + |
| 24 | + def __init__(self, user: User, project_id: int): |
| 25 | + self.project = user._make_linked_object("id", project_id, project.Project, exceptions.ProjectNotFound) |
| 26 | + self.projecturl = self.project.url |
| 27 | + self.code = ''.join(random.choices(string.ascii_letters + string.digits, k=8)) |
| 28 | + self.username = user.username |
| 29 | + |
| 30 | + def check(self) -> bool: |
| 31 | + return bool(list(filter(lambda x : x.author_name == self.username and (x.content == self.code or x.content.startswith(self.code) or x.content.endswith(self.code)), self.project.comments()))) |
| 32 | + |
22 | 33 | class User(BaseSiteComponent):
|
23 | 34 |
|
24 | 35 | '''
|
@@ -799,20 +810,8 @@ def verify_identity(self, *, verification_project_id=395330233):
|
799 | 810 | It will return True if the user commented the code.
|
800 | 811 | """
|
801 | 812 |
|
802 |
| - class Verificator: |
803 |
| - |
804 |
| - def __init__(self, user): |
805 |
| - self.project = user._make_linked_object("id", verification_project_id, project.Project, exceptions.ProjectNotFound) |
806 |
| - self.projecturl = self.project.url |
807 |
| - self.code = ''.join(random.choices(string.ascii_letters + string.digits, k=130)) |
808 |
| - self.username = user.username |
809 |
| - |
810 |
| - def check(self): |
811 |
| - return list(filter(lambda x : x.author_name == self.username, self.project.comments())) != [] |
812 |
| - |
813 |
| - v = Verificator(self) |
814 |
| - print(f"{self.username} has to go to {v.projecturl} and comment {v.code} to verify their identity") |
815 |
| - return Verificator(self) |
| 813 | + v = Verificator(self, verification_project_id) |
| 814 | + return v |
816 | 815 |
|
817 | 816 | # ------ #
|
818 | 817 |
|
|
0 commit comments