Skip to content

Commit

Permalink
Merge pull request #61 from CS222-UIUC/aden/fix-oauth
Browse files Browse the repository at this point in the history
fix oauth …
  • Loading branch information
akrakman authored Dec 6, 2022
2 parents 03c718e + 0511ddf commit 187eb73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def authorize():
resp.raise_for_status() # check status code
user_info = resp.json() # convert to json
# query database for username and create session
page = UserPage(user_info["email"])
session["username"] = page.get_user(user_info["email"]).username
return (
redirect("http://localhost:3000"),
301,
) # necessary status code for Flask to auto-redirect
get = UserPage("").get_user(user_info["email"])
if get.email != "" and get.user_id != "":
session["username"] = get.username
return redirect("http://localhost:3000"), 301
# necessary status code for Flask to auto-redirect
return redirect("http://localhost:3000/login"), 301


@app.route("/login", methods=["GET", "POST"])
Expand Down
2 changes: 0 additions & 2 deletions src/backend/pages/mainpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,13 @@ def delete_apartment_review(self, apt_id: int, user: str) -> List[Review]:
def check_user_reviewed(self, apt_id: int, user: str) -> bool:
"""Check if review exists for an user"""
user_id = self.get_user_id_from_user(user)
print(user_id)
review = self.check_user_reviewed.cursor.execute(
"SELECT * FROM Reviews WHERE (apt_id = ? AND user_id = ?)",
(
apt_id,
user_id,
),
).fetchone()
print(review)
return review is not None

@use_database
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pages/userpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, name: str) -> None:

@use_database
def get_user(self, query_sql: str) -> User:
"""Return User object based on username"""
"""Return User object based on username or email"""
user_query = self.get_user.cursor.execute(
"SELECT u.user_id, u.username, u.password, u.email, u.phone \
FROM USERS u\
Expand Down

3 comments on commit 187eb73

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py1731094%47–58
auth.py90100% 
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py160100% 
   review.py70100% 
   user.py80100% 
pages
   login.py290100% 
   mainpage.py1180100% 
   userpage.py530100% 
TOTAL4501098% 

Tests Skipped Failures Errors Time
54 0 💤 0 ❌ 0 🔥 1.293s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py1731094%47–58
auth.py90100% 
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py160100% 
   review.py70100% 
   user.py80100% 
pages
   login.py290100% 
   mainpage.py1180100% 
   userpage.py530100% 
TOTAL4501098% 

Tests Skipped Failures Errors Time
54 0 💤 0 ❌ 0 🔥 1.552s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py1731094%47–58
auth.py90100% 
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py160100% 
   review.py70100% 
   user.py80100% 
pages
   login.py290100% 
   mainpage.py1180100% 
   userpage.py530100% 
TOTAL4501098% 

Tests Skipped Failures Errors Time
54 0 💤 0 ❌ 0 🔥 1.886s ⏱️

Please sign in to comment.