Skip to content

Commit

Permalink
going back checked src works fine
Browse files Browse the repository at this point in the history
  • Loading branch information
SirGankalot committed Jun 16, 2024
1 parent f272787 commit d212dcf
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 1,108 deletions.
8 changes: 7 additions & 1 deletion service/src/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ async def sign_up():
final_text = ""
for j in text:
final_text += j

private_key_text = private_key.split('\n')
text = private_key_text[1:-2]
final_private_key_text = ""
for j in text:
final_private_key_text += j

new_user = User(email=email, first_name=first_name, private_key=private_key, public_key=public_key, public_key_name = final_text, password= password1, time = datetime.datetime.now())
new_user = User(email=email, first_name=first_name, private_key=private_key, public_key=public_key, public_key_name = final_text, private_key_name = final_private_key_text ,password= password1, time = datetime.datetime.now())
db.session.add(new_user)
db.session.commit()
login_user(new_user, remember=True) # missing await?
Expand Down
6 changes: 6 additions & 0 deletions service/src/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
db.Column('group_id', db.Integer, db.ForeignKey('NoteGroup.id'))
)

user_friends_association = db.Table('user_friends_association',
db.Column('user_id', db.Integer, db.ForeignKey('User.id')),
db.Column('friend_id', db.Integer, db.ForeignKey('User.id'))
)

class NoteGroup(db.Model):
__tablename__ = 'NoteGroup'
id = db.Column(db.Integer, primary_key=True)
Expand Down Expand Up @@ -51,6 +56,7 @@ class User(db.Model, UserMixin):
private_key = db.Column(db.String(255), unique=True)
public_key = db.Column(db.String(255), unique=True)
public_key_name = db.Column(db.String(255), unique=True)
private_key_name = db.Column(db.String(255), unique=True)
status = db.Column(db.String(255))
time = db.Column(db.DateTime(timezone=True), default=func.now())

Expand Down
41 changes: 40 additions & 1 deletion service/src/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .models import User
from .models import user_group_association
from .models import NoteOfGroup
from .models import user_friends_association
from . import db
import json
import datetime as dt
Expand Down Expand Up @@ -230,4 +231,42 @@ async def profil():
current_user.status = status
db.session.commit()
flash('Profile updated!', category='success')
return render_template("profil.html", user=current_user, groups=Note_groups)
return render_template("profil.html", user=current_user, groups=Note_groups)


# @views.route('/add_friend', methods=['GET', 'POST'])
# @login_required
# async def add_friend_headfunction():
# if request.method == 'POST':
# if 'accept_friend' in request.form:
# user_email = request.form.get('user.email')
# print(user_email)

# elif 'reject_friend' in request.form:
# user_email = request.form.get('user.email')
# print(user_email)

# elif 'add_friend' in request.form:
# friend_email = request.form.get('friend_email')
# print(friend_email)
# add_friend(friend_email)
# #return add_friend(friend_email)
# else:
# users = User.query.all()
# user_list = []
# for user in users:
# if user.email != current_user.email:
# user_list.append(user)
# return render_template("add_friend.html", users=user_list)

# # def accept_friend():

# # def reject_friend():

# def add_friend(friend_email):
# if len(friend_email) < 1:
# flash('Friend email is too short!', category='error')
# elif db.session.query(User).filter_by(email=friend_email).first():



60 changes: 0 additions & 60 deletions service/src_old/__init__.py

This file was deleted.

42 changes: 0 additions & 42 deletions service/src_old/aes_encryption.py

This file was deleted.

98 changes: 0 additions & 98 deletions service/src_old/auth.py

This file was deleted.

58 changes: 0 additions & 58 deletions service/src_old/cleanup.py

This file was deleted.

Loading

0 comments on commit d212dcf

Please sign in to comment.