Site
- change proba for easter egg - add invit on profil page - add pie stat on profil page - settings are ready, just wait for popup to confirm delete account - add spotlight on home apge - fix bug camera mouvement when it move into screen - add settings button on all top bar Django - update function changePrivateInfo
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
<img id="github" src="/static/img/profilPage/github.png">
|
||||
<img id="discord" src="/static/img/profilPage/discord.webp">
|
||||
<img id="newConv" src="/static/img/profilPage/addConv.png">
|
||||
<img id="invite" src="/static/img/profilPage/invite.png">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -20,6 +21,11 @@
|
||||
<div class="content">
|
||||
<div class="dashboard">
|
||||
<h3>Dashboard</h3>
|
||||
<div class="contentStats">
|
||||
<canvas id="stats">
|
||||
|
||||
</canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="history">
|
||||
<h3>History</h3>
|
||||
|
@ -1,3 +1,14 @@
|
||||
<div id="topBar">
|
||||
<h1 id="homeButton">METH</h1>
|
||||
<div id="loginButton">
|
||||
<p>LOGIN</p>
|
||||
</div>
|
||||
<div id="popMenuLoginButton">
|
||||
<p>Profil</p>
|
||||
<p>Settings</p>
|
||||
<p>Logout</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="settingsBody">
|
||||
<div class="container-settings">
|
||||
<div class="left-section">
|
||||
@ -45,11 +56,13 @@
|
||||
<input type="password" id="confirm-password" placeholder="Confirm password">
|
||||
<div class="form-footer">
|
||||
<small>We advise you to change your password regularly to reduce the risk of unauthorized access.</small>
|
||||
<button class="save-btn-settings">SAVE</button>
|
||||
<button class="save-btn-settings" id="passwordButtonSave">SAVE</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="delete-btn">Delete the account</button>
|
||||
<button class="delete-btn" id="deleteButton">Delete the account</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="divNotification">
|
||||
</div>
|
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/09/25 23:28:49 by edbernar #+# #+# #
|
||||
# Updated: 2024/09/26 00:41:16 by edbernar ### ########.fr #
|
||||
# Updated: 2024/09/26 14:56:22 by edbernar ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -26,13 +26,22 @@ def changePrivateInfo(socket, content):
|
||||
data = []
|
||||
if (content.get("username")):
|
||||
data.append("username")
|
||||
if (content.get("password")):
|
||||
data.append("password")
|
||||
if (content.get("new_password")):
|
||||
data.append("new_password")
|
||||
if (content.get("discord")):
|
||||
data.append("discord")
|
||||
if (content.get("delete")):
|
||||
data.append("delete")
|
||||
if (len(data) != 1):
|
||||
socket.sendError("You must provide exactly one field to update", 9028)
|
||||
return
|
||||
if (content.get("delete")):
|
||||
user = User.objects.get(id=socket.id)
|
||||
user.delete()
|
||||
socket.scope["session"].delete()
|
||||
socket.sync_send(json.dumps({"type": "change_private_info", "content": "Successfully deleted."}))
|
||||
socket.close()
|
||||
return
|
||||
if (content.get("username")):
|
||||
if (content["username"].find(' ') != -1):
|
||||
socket.sendError("Username must not contain spaces", 9015)
|
||||
@ -49,15 +58,18 @@ def changePrivateInfo(socket, content):
|
||||
if (User.objects.filter(username=content["username"]).exists()):
|
||||
socket.sendError("Username already used", 9023)
|
||||
return
|
||||
if (content.get("password")):
|
||||
if (len(content["password"]) < 8):
|
||||
if (content.get("new_password")):
|
||||
if (not content.get("old_password")):
|
||||
raise Exception("Old password is required")
|
||||
if (len(content["new_password"]) < 8):
|
||||
socket.sendError("Password must be at least 8 characters long", 9019)
|
||||
return
|
||||
if (content["password"].find(content["username"]) != -1):
|
||||
if (content["new_password"].find(str(content.get("username"))) != -1):
|
||||
socket.sendError("Password must not contain the username", 9021)
|
||||
return
|
||||
if (not bool(re.match(password_pattern, content["password"]))):
|
||||
socket.sendError("Password must contain at least one lowercase letter, one uppercase letter and one special character", 9020)
|
||||
if (not bool(re.match(password_pattern, content["new_password"]))):
|
||||
return
|
||||
if (content.get("discord")):
|
||||
if (len(content["discord"]) > 32):
|
||||
@ -72,8 +84,11 @@ def changePrivateInfo(socket, content):
|
||||
user.username = content["username"]
|
||||
socket.username = content["username"]
|
||||
socket.scope["session"]['username'] = content["username"]
|
||||
if (content.get("password")):
|
||||
user.password = hashlib.sha256(user['mail' + content["password"]].encode()).hexdigest()
|
||||
if (content.get("new_password")):
|
||||
if (hashlib.md5((user.mail + content["old_password"]).encode()).hexdigest() != user.password):
|
||||
socket.sendError("Invalid password", 9029)
|
||||
return
|
||||
user.password = hashlib.md5((user.mail + content["new_password"]).encode()).hexdigest()
|
||||
if (content.get("discord")):
|
||||
if (content["discord"] != ""):
|
||||
user.discord_username = content["discord"]
|
||||
|
Reference in New Issue
Block a user