Gregniuki commited on
Commit
274371f
1 Parent(s): 9034fa5

Update auth.py

Browse files
Files changed (1) hide show
  1. auth.py +3 -4
auth.py CHANGED
@@ -41,16 +41,15 @@ class UserCreate(BaseModel):
41
 
42
  from emailx import send_verification_email, generate_verification_token
43
 
44
- # ...
45
 
46
- def register(self, user: UserCreate, db: Session = Depends(get_db)):
47
  # Validate email format and check for existing users
48
  db_user = get_user_by_email(db, user.email)
49
  if db_user:
50
  raise HTTPException(status_code=400, detail="Email already registered")
51
 
52
  # Hash the password
53
- hashed_password = self.pwd_context.hash(user.password)
54
 
55
  # Generate a verification token
56
  verification_token = generate_verification_token(user.email)
@@ -59,7 +58,7 @@ def register(self, user: UserCreate, db: Session = Depends(get_db)):
59
  send_verification_email(user.email, verification_token)
60
 
61
  # Create the user in the database
62
- user_in_db = models.User(email=user.email, hashed_password=hashed_password)
63
  db.add(user_in_db)
64
  db.commit()
65
  db.refresh(user_in_db)
 
41
 
42
  from emailx import send_verification_email, generate_verification_token
43
 
 
44
 
45
+ def register(user: UserCreate, db: Session):
46
  # Validate email format and check for existing users
47
  db_user = get_user_by_email(db, user.email)
48
  if db_user:
49
  raise HTTPException(status_code=400, detail="Email already registered")
50
 
51
  # Hash the password
52
+ hashed_password = pwd_context.hash(user.password)
53
 
54
  # Generate a verification token
55
  verification_token = generate_verification_token(user.email)
 
58
  send_verification_email(user.email, verification_token)
59
 
60
  # Create the user in the database
61
+ user_in_db = User(email=user.email, hashed_password=hashed_password)
62
  db.add(user_in_db)
63
  db.commit()
64
  db.refresh(user_in_db)