Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
idatg2204-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Steffen Martinsen
idatg2204-project
Commits
d22d6087
Commit
d22d6087
authored
May 8, 2024
by
Knut Fineid
Browse files
Options
Downloads
Patches
Plain Diff
small fixes on order payment, log out, and register
parent
0497fa61
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Backend/routes/login.py
+10
-2
10 additions, 2 deletions
Backend/routes/login.py
Backend/routes/order.py
+2
-2
2 additions, 2 deletions
Backend/routes/order.py
with
12 additions
and
4 deletions
Backend/routes/login.py
+
10
−
2
View file @
d22d6087
...
...
@@ -3,6 +3,10 @@ from flask import request, jsonify, make_response
import
bcrypt
def
post_logout
():
userId
=
request
.
cookies
.
get
(
'
logged_in
'
)
if
userId
is
None
:
return
jsonify
({
"
message
"
:
"
No user logged in
"
}),
400
response
=
make_response
(
jsonify
({
"
message
"
:
"
Logout successful
"
}))
# Cookie expires immediately
response
.
set_cookie
(
'
logged_in
'
,
''
,
expires
=
0
)
...
...
@@ -50,6 +54,11 @@ def post_login():
return
response
,
200
def
post_register
():
# Make sure we are not already logged in to another user
userId
=
request
.
cookies
.
get
(
'
logged_in
'
)
if
userId
is
not
None
:
return
jsonify
({
"
message
"
:
"
A user is already logged in
"
}),
400
# Get data from request
data
=
request
.
json
email
=
data
[
'
email
'
]
...
...
@@ -87,4 +96,3 @@ def hash_function(password, salt):
# Hash the password and return the hashed value
hashed
=
bcrypt
.
hashpw
(
password
,
salt
)
return
hashed
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Backend/routes/order.py
+
2
−
2
View file @
d22d6087
...
...
@@ -111,8 +111,8 @@ def pay_order():
# Get the order status to make sure the order is not already paid
cur
=
mysql
.
connection
.
cursor
()
cur
.
execute
(
'''
SELECT user_order.status, user_order.total_amount, user.user_id
FROM user_order
INNER JOIN user ON user_order.user_id = user.user_id
cur
.
execute
(
'''
SELECT user_order.status, user_order.total_amount, user
_order
.user_id
FROM user_order
WHERE order_id = %s
'''
,
(
order_id
,))
order_info
=
cur
.
fetchall
()
cur
.
close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment