Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes #4

Open
wants to merge 2 commits into
base: stage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ Helper for the Pool1/2 architecture.
```
please asp set -f file #change asps via csv

```
```

## User

```
please users confirm <email> # Confirm an user.
please users delete <email> # Deletes an user.
please users change_password <email> # Generate new password.
```
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ requests==2.27.1
tqdm==4.64.0
urllib3==1.26.9
pydantic
bcrypt
Binary file removed src/__pycache__/address.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/address.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/asps.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/asps.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/crews.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/crews.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/event_stats.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/event_stats.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/newsletter.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/newsletter.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/profile.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/profile.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/result.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/result.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/user.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/user.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/user_crew.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/user_crew.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/utils.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/utils.cpython-37.pyc
Binary file not shown.
24 changes: 23 additions & 1 deletion src/user.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from sqlite3 import Cursor
from pydantic import BaseModel
import pymysql, pymysql.cursors, os, copy, uuid
from dotenv import load_dotenv
import requests
from tqdm import tqdm
import pprint
import random, bcrypt

from .result import Result

Expand Down Expand Up @@ -295,7 +297,25 @@ def get(self, email):
cursor.execute(sql, email)
database_result = cursor.fetchone()
print(database_result)


def change_password(self, email):
password = ''
for _ in range(20):
random_integer = random.randint(33, 122)
password += (chr(random_integer))
password_bytes = bytes(password, 'utf8')
password_hashed = bcrypt.hashpw(password_bytes, bcrypt.gensalt(10))
sql_update='update PasswordInfo as pi left join Profile as p on p.id = pi.profile_id set password = "' + password_hashed.decode() +'" where p.email = %s'
with self.drops.cursor() as cursor:
cursor.execute(sql_update, email)
result = cursor.fetchone()
sql = 'select * from Profile as p left join PasswordInfo as pi on pi.profile_id = p.id where email = %s'
with self.drops.cursor() as cursor:
cursor.execute(sql, email)
result = cursor.fetchone()
if not bcrypt.checkpw(password_bytes, result["password"].encode("utf-8")):
print("Error: password not matching with database. Try again." )
print("Password is: ", password)
def delete(self, email):
sql = "select p.id as p_id, u.id as u_id, s.id as s_id from User as u left join Profile as p on p.user_id = u.id left join Supporter as s on s.profile_id = p.id where email = %s"
u_id = 0
Expand Down Expand Up @@ -359,5 +379,7 @@ def process(self, argv):
if argv[2] == 'export':
result = self.all()
self.export(result)
if argv[2] == 'change_password':
self.change_password(argv[3])