Skip to content

Commit

Permalink
Made changes (removed debug statements, moved stuff to .env file)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jwdegames committed Nov 28, 2023
1 parent 5b0784c commit 14b7969
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 72 deletions.
13 changes: 4 additions & 9 deletions backend/app/api/endpoints/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

load_dotenv()
JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY")
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 30
ALGORITHM = os.getenv("ALGORITHM")
ACCESS_TOKEN_EXPIRE_MINUTES = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES"))

# Google Client ID
CLIENT_ID = "710734565405-3nkf5plf0m4p460osals94rnksheoh93.apps.googleusercontent.com"
CLIENT_ID = os.getenv("CLIENT_ID")

users_db = get_db()

Expand Down Expand Up @@ -195,14 +195,12 @@ async def delete_user(
async def google_login(token: str, db: Session = Depends(get_db)):
try:
# Specify the CLIENT_ID of the app that accesses the backend:
print("testing:", token)
idinfo = id_token.verify_oauth2_token(
token,
requests.Request(),
CLIENT_ID,
clock_skew_in_seconds=1000000,
)
print("Success")
# print("ID_info:", idinfo)
# Or, if multiple clients access the backend server:
# idinfo = id_token.verify_oauth2_token(token, requests.Request())
Expand Down Expand Up @@ -239,7 +237,6 @@ async def google_login(token: str, db: Session = Depends(get_db)):
user = new_user
else:
user = user[0]
print(user.username)
access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
access_token = create_access_token(
data={"sub": user.username}, expires_delta=access_token_expires
Expand All @@ -248,6 +245,4 @@ async def google_login(token: str, db: Session = Depends(get_db)):

except ValueError as e:
# Invalid token
print("Invalid token:", token)
print(e)
return {"Error!"}
return {"Error": e}
57 changes: 0 additions & 57 deletions debugdump.txt

This file was deleted.

1 change: 0 additions & 1 deletion frontend/src/_generated/api/services/LoginService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export class LoginService {
public static googleLogin(
token: string,
): CancelablePromise<any> {
console.log("Testing");
return __request(OpenAPI, {
method: 'POST',
url: '/login/users/google-login',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@ export class GoogleSignInComponent implements OnInit {
}

async handleCredentialResponse(googleUser: any) {
console.log(googleUser);
var token: string = googleUser.credential;

LoginService.googleLogin(token).then(
() => {
// login
console.log('Resetting');
this.loginRef.form.reset();
console.log('Navigating');
this.zone.run(() => this.loginRef.router.navigate(['/jobs']));
},
() => {
// Do nothing since we failed
console.log('Failed');
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bcrypt==4.0.1
celery[redis]
fastapi==0.95.2
google-api-python-client
google-api-python-client==2.108.0
nltk==3.8.1
passlib[bcrypt]==1.7.4
pre-commit==3.5.0
Expand Down

0 comments on commit 14b7969

Please sign in to comment.