Update auth.py
Browse files
auth.py
CHANGED
@@ -19,6 +19,13 @@ class AuthViews:
|
|
19 |
self.SECRET_KEY = yoursecretkey # Replace with your actual secret key
|
20 |
self.ALGORITHM = "HS256"
|
21 |
self.ACCESS_TOKEN_EXPIRE_MINUTES = 30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
auth_views = AuthViews()
|
23 |
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
24 |
|
@@ -115,12 +122,7 @@ def get_current_user(token: str = Depends(verify_token)):
|
|
115 |
raise HTTPException(status_code=401, detail="Token not valid")
|
116 |
return token
|
117 |
|
118 |
-
|
119 |
-
to_encode = data.copy()
|
120 |
-
expire = datetime.utcnow() + expires_delta
|
121 |
-
to_encode.update({"exp": expire})
|
122 |
-
encoded_jwt = jwt.encode(to_encode, AuthViews().SECRET_KEY, algorithm=AuthViews().ALGORITHM)
|
123 |
-
return encoded_jwt
|
124 |
|
125 |
|
126 |
|
|
|
19 |
self.SECRET_KEY = yoursecretkey # Replace with your actual secret key
|
20 |
self.ALGORITHM = "HS256"
|
21 |
self.ACCESS_TOKEN_EXPIRE_MINUTES = 30
|
22 |
+
def create_access_token(self, data: dict, expires_delta: timedelta):
|
23 |
+
to_encode = data.copy()
|
24 |
+
expire = datetime.utcnow() + expires_delta
|
25 |
+
to_encode.update({"exp": expire})
|
26 |
+
encoded_jwt = jwt.encode(to_encode, AuthViews().SECRET_KEY, algorithm=AuthViews().ALGORITHM)
|
27 |
+
return encoded_jwt
|
28 |
+
|
29 |
auth_views = AuthViews()
|
30 |
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
31 |
|
|
|
122 |
raise HTTPException(status_code=401, detail="Token not valid")
|
123 |
return token
|
124 |
|
125 |
+
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
|
128 |
|