feat: complete platform overhaul, bugfixes, and verified production release

This commit is contained in:
Atharv1705
2026-10-28 21:47:48 +05:30
parent 276039a743
commit 3cb6229cd9
62 changed files with 1820 additions and 548 deletions
+11 -9
View File
@@ -96,7 +96,7 @@ async def forgot_password(
reset_token = create_password_reset_token(user.email)
frontend_url = os.getenv("FRONTEND_URL", "https://aiindiacpa.duckdns.org")
frontend_url = os.getenv("FRONTEND_URL", "https://aicpa.duckdns.org")
reset_link = f"{frontend_url}/reset-password?token={reset_token}"
reset_body = (
@@ -267,7 +267,7 @@ async def signup(request: Request, payload: SignupRequest, background: Backgroun
# Send verification email in background (non-blocking)
if not is_admin:
verify_token = create_email_verification_token(user.email)
frontend_url = os.getenv("FRONTEND_URL", "https://aiindiacpa.duckdns.org")
frontend_url = os.getenv("FRONTEND_URL", "https://aicpa.duckdns.org")
verify_link = f"{frontend_url}/verify-email?token={verify_token}"
verify_body = (
f"Hi {user.name},<br><br>"
@@ -376,7 +376,7 @@ async def resend_verification(
return {"message": "If the email exists and is unverified, a new link has been sent"}
verify_token = create_email_verification_token(user.email)
frontend_url = os.getenv("FRONTEND_URL", "https://aiindiacpa.duckdns.org")
frontend_url = os.getenv("FRONTEND_URL", "https://aicpa.duckdns.org")
verify_link = f"{frontend_url}/verify-email?token={verify_token}"
resend_body = (
@@ -446,18 +446,20 @@ def update_me(
current_user=Depends(get_current_user),
):
"""Update own profile (name, phone, password). Any authenticated user."""
name = payload.get("name", "").strip()
phone = payload.get("phone", "").strip()
current_pw = payload.get("current_password", "")
new_pw = payload.get("new_password", "")
name_raw = payload.get("name")
phone_raw = payload.get("phone")
name = name_raw.strip() if isinstance(name_raw, str) else None
phone = phone_raw.strip() if isinstance(phone_raw, str) else None
current_pw = payload.get("current_password") or ""
new_pw = payload.get("new_password") or ""
changed = []
if name and name != current_user.name:
if name is not None and name and name != current_user.name:
current_user.name = name
changed.append("name")
if phone != current_user.phone:
if phone is not None and phone != (current_user.phone or ""):
current_user.phone = phone
changed.append("phone")
+2
View File
@@ -194,6 +194,8 @@ def llms_txt():
@app.get("/{full_path:path}", tags=["frontend"])
def spa_fallback(full_path: str):
if full_path.startswith("api/") or full_path == "api":
raise HTTPException(status_code=404, detail="API endpoint not found")
if os.path.isfile(SPA_INDEX):
return FileResponse(
SPA_INDEX,
+24
View File
@@ -256,11 +256,35 @@ def admin_bulk_action(
model_class.deleted_at == None,
).all()
from app import crud
from app.models import DocumentReviewEvent
from datetime import datetime
count = 0
for doc in docs:
doc.review_status = new_status
if new_status == "approved":
doc.reviewed_at = datetime.utcnow()
event = DocumentReviewEvent(
doc_kind=doc_type,
doc_id=doc.id,
owner_user_id=payload.user_id,
actor_id=current_user.id,
actor_role="admin",
action=f"bulk_{new_status}",
from_status="pending",
to_status=new_status,
tax_year=doc.tax_year,
)
db.add(event)
count += 1
crud.log_action(
db, "bulk_review_docs",
user_id=current_user.id,
target=f"user:{payload.user_id}",
detail=f"bulk_{new_status} {count} {doc_type} documents",
)
db.commit()
logger.info(f"Admin {current_user.id} bulk {new_status} {count} {doc_type} docs for user {payload.user_id}")
+13 -6
View File
@@ -1,4 +1,5 @@
import os
import html
from fastapi import APIRouter, BackgroundTasks, HTTPException, Request
from app.limiter import limiter
from pydantic import BaseModel, EmailStr, field_validator
@@ -7,7 +8,7 @@ from app.utils.emailer import send_email
router = APIRouter(prefix="/api", tags=["contact"])
# Get admin email from environment, with fallback
ADMIN_EMAIL = os.getenv("ADMIN_EMAIL", "admin@bookkeepro.net")
ADMIN_EMAIL = os.getenv("ADMIN_EMAIL", "atharvg.aiindia@gmail.com")
class ContactForm(BaseModel):
first_name: str
@@ -28,6 +29,12 @@ class ContactForm(BaseModel):
async def contact_message(request: Request, form: ContactForm, background: BackgroundTasks):
if not ADMIN_EMAIL or "@" not in ADMIN_EMAIL:
raise HTTPException(status_code=500, detail="Admin email not configured")
safe_first = html.escape(form.first_name)
safe_last = html.escape(form.last_name)
safe_email = html.escape(str(form.email))
safe_phone = html.escape(form.phone)
safe_message = html.escape(form.message) if form.message else '(none)'
background.add_task(
send_email,
to=ADMIN_EMAIL,
@@ -37,10 +44,10 @@ async def contact_message(request: Request, form: ContactForm, background: Backg
<br><br>
A new contact enquiry has been received. Please find the details below:
<br><br>
<b>Name:</b> {form.first_name} {form.last_name}<br>
<b>Email:</b> {form.email}<br>
<b>Phone:</b> {form.phone}<br>
<b>Message:</b> {form.message or '(none)'}<br><br>
<b>Name:</b> {safe_first} {safe_last}<br>
<b>Email:</b> {safe_email}<br>
<b>Phone:</b> {safe_phone}<br>
<b>Message:</b> {safe_message}<br><br>
Kindly follow up with the user at the earliest convenience.
<br><br>
Thank you,<br>
@@ -54,7 +61,7 @@ async def contact_message(request: Request, form: ContactForm, background: Backg
to=form.email,
subject="Thanks for contacting BookKeepro",
body=f"""
Hi {form.first_name},<br><br>
Hi {safe_first},<br><br>
Thank you for reaching out to BookKeepro.<br>
We’ve received your enquiry, and our team will get back to you shortly.<br><br>
Best Regards,<br>
+51 -20
View File
@@ -1,5 +1,5 @@
import os
from datetime import date, timedelta
from datetime import date, datetime, timedelta
import logging
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException
from sqlalchemy.orm import Session
@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
router = APIRouter(prefix="/api/review", tags=["review"])
DASHBOARD_LINK = f"{os.getenv('FRONTEND_URL', 'https://aiindiacpa.duckdns.org')}/dashboard"
DASHBOARD_LINK = f"{os.getenv('FRONTEND_URL', 'https://aicpa.duckdns.org')}/dashboard"
# ─────────────────────────────────────────────
@@ -127,6 +127,7 @@ async def notify_user_review(
@router.post("/admin-doc-response")
async def admin_doc_response(
payload: AdminDocResponseRequest,
background: BackgroundTasks,
db: Session = Depends(get_db),
current_user=Depends(get_current_user),
):
@@ -147,6 +148,7 @@ async def admin_doc_response(
raise HTTPException(status_code=403, detail="Not authorized")
doc.review_status = payload.status
doc.reviewed_at = datetime.utcnow()
if payload.reason:
doc.review_note = payload.reason
db.commit()
@@ -166,28 +168,29 @@ async def admin_doc_response(
db.add(event)
db.commit()
admin = db.query(User).filter_by(id=doc.uploaded_by).first()
if not admin:
raise HTTPException(status_code=404, detail="Admin not found")
admin = db.query(User).filter_by(id=doc.uploaded_by).first() if doc.uploaded_by else None
admin_email = admin.email if admin else os.getenv("ADMIN_EMAIL")
body = f"""
<p>Dear Admin,</p>
<p>User <b>{current_user.email}</b> has <b>{payload.status.upper()}</b> the document:</p>
<p><b>{doc.doc_label}</b></p>
"""
if payload.status == "rejected" and payload.reason:
body += f"<p><strong>Reason:</strong></p><p>{payload.reason}</p>"
if admin_email:
body = f"""
<p>Dear Admin,</p>
<p>User <b>{current_user.email}</b> has <b>{payload.status.upper()}</b> the document:</p>
<p><b>{doc.doc_label}</b></p>
"""
if payload.status == "rejected" and payload.reason:
body += f"<p><strong>Reason:</strong></p><p>{payload.reason}</p>"
body += "<p style='margin-top:20px;'>BookKeepro System</p>"
body += "<p style='margin-top:20px;'>BookKeepro System</p>"
await send_email(
to=admin.email,
subject=f"Admin Return Status {payload.status.capitalize()} — BookKeepro",
body=body,
)
background.add_task(
send_email,
to=admin_email,
subject=f"Admin Return Status {payload.status.capitalize()} — BookKeepro",
body=body,
)
logger.info(f"User {current_user.id} {payload.status} admin doc {payload.doc_id}")
return {"status": "notified"}
return {"status": "notified", "review_status": doc.review_status}
# ─────────────────────────────────────────────
# Update Status and History
@@ -279,13 +282,40 @@ def update_document_status(
# Get filing deadlines for a user
# ─────────────────────────────────────────────
@router.get("/my-deadlines")
def get_my_filing_deadlines(
db: Session = Depends(get_db),
current_user=Depends(get_current_user),
):
from app.models import FilingDeadline
deadlines = db.query(FilingDeadline).filter(FilingDeadline.user_id == current_user.id).all()
today = date.today()
result = []
for dl in deadlines:
days_left = (dl.deadline_date - today).days
result.append({
"id": dl.id,
"doc_type": dl.doc_type,
"deadline_date": dl.deadline_date.isoformat(),
"days_given": dl.days_given,
"days_left": days_left,
"is_overdue": days_left < 0,
})
return result
@router.get("/deadlines/{user_id}")
def get_filing_deadlines(
user_id: int,
db: Session = Depends(get_db),
current_user=Depends(get_current_user),
_=Depends(require_admin),
):
is_admin = current_user.role in ("admin", "super_admin") or (
hasattr(current_user.role, "value") and current_user.role.value in ("admin", "super_admin")
)
if not is_admin and current_user.id != user_id:
raise HTTPException(status_code=403, detail="Not authorized to view these deadlines")
from app.models import FilingDeadline
deadlines = db.query(FilingDeadline).filter(FilingDeadline.user_id == user_id).all()
today = date.today()
@@ -293,6 +323,7 @@ def get_filing_deadlines(
for dl in deadlines:
days_left = (dl.deadline_date - today).days
result.append({
"id": dl.id,
"doc_type": dl.doc_type,
"deadline_date": dl.deadline_date.isoformat(),
"days_given": dl.days_given,
+22 -13
View File
@@ -29,7 +29,7 @@ router = APIRouter(prefix="/api/upload", tags=["upload"])
from pathlib import Path
FRONTEND_URL = os.getenv("FRONTEND_URL", "https://aiindiacpa.duckdns.org")
FRONTEND_URL = os.getenv("FRONTEND_URL", "https://aicpa.duckdns.org")
# ─────────────────────────────────────────────
# Local File Storage (Contabo VPS Disk)
@@ -282,9 +282,12 @@ async def upload_admin_document(
logger.info(f"Admin {current_user.id} uploading document for user {user_id}")
storage_key = await upload_to_storage(file)
safe_doc_key = (doc_key or "").strip()[:100]
safe_doc_label = (doc_label or "").strip()[:150]
record = AdminDocument(
doc_key=doc_key,
doc_label=doc_label,
doc_key=safe_doc_key,
doc_label=safe_doc_label,
filename=file.filename,
storage_key=storage_key,
content_type=file.content_type,
@@ -415,6 +418,12 @@ def delete_admin_document(
detail="Standard admins can only manage documents for standard users"
)
if doc.review_status == "approved":
raise HTTPException(
status_code=400,
detail="Cannot delete an approved return. Approved documents are locked."
)
logger.info(f"Admin {current_user.id} deleting admin document {doc_id}")
delete_from_storage(doc.storage_key)
doc.deleted_at = datetime.utcnow()
@@ -819,7 +828,7 @@ async def set_personal_review_status(
subject="Action Required: Document Rejected — BookKeepro",
body=f"""
<p>Dear {owner.name or 'Client'},</p>
<p>Your personal document <strong>{doc.doc_type}</strong> (Tax Year {doc.tax_year}) has been <strong style='color:#c0392b;'>rejected</strong> by our team.</p>
<p>Your personal document <strong>{doc.filename}</strong> (Tax Year {doc.tax_year}) has been <strong style='color:#c0392b;'>rejected</strong> by our team.</p>
{note_html}
<p>Please log in to your dashboard, review the reason, and re-upload a corrected document.</p>
<p><a href='{FRONTEND_URL}/upload-personal' style='color:#0077c8;font-weight:600;'>Re-upload Personal Documents →</a></p>
@@ -883,7 +892,7 @@ async def set_business_review_status(
subject="Action Required: Document Rejected — BookKeepro",
body=f"""
<p>Dear {owner.name or 'Client'},</p>
<p>Your business document <strong>{doc.business_type}</strong> (Tax Year {doc.tax_year}) has been <strong style='color:#c0392b;'>rejected</strong> by our team.</p>
<p>Your business document <strong>{doc.filename}</strong> (Tax Year {doc.tax_year}) has been <strong style='color:#c0392b;'>rejected</strong> by our team.</p>
{note_html}
<p>Please log in to your dashboard, review the reason, and re-upload a corrected document.</p>
<p><a href='{FRONTEND_URL}/upload-business' style='color:#0077c8;font-weight:600;'>Re-upload Business Documents →</a></p>
@@ -1234,17 +1243,17 @@ from app.models import RequiredDocumentTemplate
@router.get("/templates")
def list_templates(
category: str,
tax_year: int,
category: str | None = None,
tax_year: int | None = None,
db: Session = Depends(get_db),
current_user=Depends(get_current_user),
):
templates = (
db.query(RequiredDocumentTemplate)
.filter_by(category=category, tax_year=tax_year)
.order_by(RequiredDocumentTemplate.id.asc())
.all()
)
query = db.query(RequiredDocumentTemplate)
if category:
query = query.filter(RequiredDocumentTemplate.category == category)
if tax_year:
query = query.filter(RequiredDocumentTemplate.tax_year == tax_year)
templates = query.order_by(RequiredDocumentTemplate.id.asc()).all()
results = []
for t in templates:
+16 -4
View File
@@ -2,7 +2,7 @@
Document type classifier for the "other_*" catch-all upload bucket.
When a user uploads via the "Additional Documents" slot, doc_type is set to
`other_<timestamp>_<index>` — a meaningless slug. This module detects the
`other_<timestamp>_<index>` ? a meaningless slug. This module detects the
actual document type from OCR text + filename so the extraction prompt
becomes type-specific rather than generic.
@@ -24,6 +24,12 @@ class DocCategory(str, Enum):
AADHAAR = "Aadhaar Card"
W2 = "W-2 Wage Statement"
FORM_1099 = "1099 Income Form"
FORM_1040 = "Form 1040 (U.S. Individual Income Tax Return)"
FORM_1120 = "Form 1120/1120-S (U.S. Corporation Tax Return)"
FORM_1065 = "Form 1065 (U.S. Partnership Tax Return)"
SCHEDULE_K1 = "Schedule K-1"
FORM_W9 = "Form W-9 (TIN Request)"
EIN_LETTER = "IRS EIN Assignment Letter"
ENGAGEMENT_LETTER = "Engagement Letter"
TAX_ORGANIZER = "Tax Organizer"
INVOICE = "Invoice / Bill"
@@ -33,7 +39,7 @@ class DocCategory(str, Enum):
GENERIC = "Other Document"
# Priority-ordered keyword patterns — first match wins
# Priority-ordered keyword patterns ? first match wins
_PATTERNS: list[tuple[re.Pattern, DocCategory]] = [
# Government IDs
(re.compile(r'\bPERMANENT\s+ACCOUNT\s+NUMBER\b|\bINCOME\s+TAX\s+DEPT\b', re.I), DocCategory.PAN_CARD),
@@ -43,6 +49,12 @@ _PATTERNS: list[tuple[re.Pattern, DocCategory]] = [
# US Tax forms
(re.compile(r'\bW-?2\b.*\bWAGES\b|\bWAGES.*TIPS.*OTHER\b|\bFEDERAL\s+INCOME\s+TAX\s+WITHHELD\b', re.I), DocCategory.W2),
(re.compile(r'\b1099-?[A-Z]{0,4}\b|\bNONEMPLOYEE\s+COMPENSATION\b|\bMISCELLANEOUS\s+INCOME\b', re.I), DocCategory.FORM_1099),
(re.compile(r'\bFORM\s+1040\b|\b1040-?SR\b|\bU\.S\.\s+INDIVIDUAL\s+INCOME\s+TAX\s+RETURN\b', re.I), DocCategory.FORM_1040),
(re.compile(r'\bFORM\s+1120\b|\b1120-?S\b|\bU\.S\.\s+(CORPORATION|INCOME\s+TAX\s+RETURN\s+FOR\s+AN\s+S\s+CORPORATION)\b', re.I), DocCategory.FORM_1120),
(re.compile(r'\bSCHEDULE\s+K-?1\b|\bPARTNER[\'?]S\s+SHARE\s+OF\s+INCOME\b', re.I), DocCategory.SCHEDULE_K1),
(re.compile(r'\bFORM\s+1065\b|\bU\.S\.\s+RETURN\s+OF\s+PARTNERSHIP\s+INCOME\b', re.I), DocCategory.FORM_1065),
(re.compile(r'\bFORM\s+W-?9\b|\bREQUEST\s+FOR\s+TAXPAYER\s+IDENTIFICATION\b', re.I), DocCategory.FORM_W9),
(re.compile(r'\bCP\s*575\b|\bASSIGNED\s+EMPLOYER\s+IDENTIFICATION\s+NUMBER\b|\bFORM\s+SS-?4\b', re.I), DocCategory.EIN_LETTER),
# Accounting documents
(re.compile(r'\bENGAGEMENT\s+LETTER\b|\bTAX\s+RETURN\s+PREPARATION\s+SERVICES\b', re.I), DocCategory.ENGAGEMENT_LETTER),
(re.compile(r'\bTAX\s+ORGANIZER\b|\bLLC\s+TAX\b|\bS[-\s]?CORP\b|\bPARTNERSHIP\s+TAX\b', re.I), DocCategory.TAX_ORGANIZER),
@@ -61,7 +73,7 @@ def classify_other_doc(
Args:
ocr_text: Raw text extracted from the document (any amount).
filename: Original upload filename — used as a secondary hint.
filename: Original upload filename ? used as a secondary hint.
"""
corpus = f"{filename} {ocr_text}"
@@ -70,7 +82,7 @@ def classify_other_doc(
logger.info(f"[DocClassifier] Detected '{category.value}' from other_* upload")
return category
logger.info("[DocClassifier] No match — defaulting to GENERIC")
logger.info("[DocClassifier] No match ? defaulting to GENERIC")
return DocCategory.GENERIC
+2
View File
@@ -29,6 +29,8 @@ async def send_email(to: str, subject: str, body: str) -> bool:
smtp_port = int(os.getenv("SMTP_PORT", "587"))
smtp_user = os.getenv("SMTP_USER")
smtp_password = os.getenv("SMTP_PASSWORD")
if smtp_password:
smtp_password = smtp_password.replace(" ", "")
mail_from_email = os.getenv("MAIL_FROM") or smtp_user
mail_from_name = os.getenv("MAIL_FROM_NAME", "BookKeepro")
smtp_tls = os.getenv("SMTP_TLS", "True").strip().lower() == "true"
+1 -1
View File
@@ -1,7 +1,7 @@
import os
from app.utils.emailer import send_email
_FRONTEND_URL = os.getenv("FRONTEND_URL", "https://aiindiacpa.duckdns.org")
_FRONTEND_URL = os.getenv("FRONTEND_URL", "https://aicpa.duckdns.org")
async def send_signup_welcome_email(to: str, name: str | None = None):
+44 -45
View File
@@ -38,66 +38,65 @@ def _run_deadline_reminders():
).all()
admin_emails = [a.email for a in admins]
for days_out, flag_col, label in thresholds:
target_date = today + timedelta(days=days_out)
deadlines = (
db.query(FilingDeadline)
.filter(
FilingDeadline.deadline_date == target_date,
getattr(FilingDeadline, flag_col) == False,
async def _dispatch_reminders():
for days_out, flag_col, label in thresholds:
target_date = today + timedelta(days=days_out)
deadlines = (
db.query(FilingDeadline)
.filter(
FilingDeadline.deadline_date == target_date,
getattr(FilingDeadline, flag_col) == False,
)
.all()
)
.all()
)
for dl in deadlines:
user = db.query(User).filter(User.id == dl.user_id).first()
if not user:
continue
for dl in deadlines:
user = db.query(User).filter(User.id == dl.user_id).first()
if not user:
continue
doc_label = dl.doc_type.capitalize()
doc_label = dl.doc_type.capitalize()
# Email to user
user_body = f"""
<p>Dear {user.name or "Sir/Ma'am"},</p>
<p>This is a reminder that your <strong>{doc_label} document filing deadline</strong>
is in <strong>{label}</strong> ({dl.deadline_date.strftime('%B %d, %Y')}).</p>
<p>Please ensure all outstanding actions are completed before the deadline.</p>
<p>Kind regards,<br><strong>BookKeepro Team</strong></p>
"""
asyncio.run(
send_email(
# Email to user
user_body = f"""
<p>Dear {user.name or "Sir/Ma'am"},</p>
<p>This is a reminder that your <strong>{doc_label} document filing deadline</strong>
is in <strong>{label}</strong> ({dl.deadline_date.strftime('%B %d, %Y')}).</p>
<p>Please ensure all outstanding actions are completed before the deadline.</p>
<p>Kind regards,<br><strong>BookKeepro Team</strong></p>
"""
await send_email(
to=user.email,
subject=f"Reminder: {doc_label} Filing Deadline in {label} — BookKeepro",
body=user_body,
)
)
# Email to all admins
admin_body = f"""
<p>Admin Notice:</p>
<p>The <strong>{doc_label} filing deadline</strong> for client
<strong>{user.name or user.email}</strong> ({user.email}) is in
<strong>{label}</strong> ({dl.deadline_date.strftime('%B %d, %Y')}).</p>
<p>Please review the client's status and take any necessary action.</p>
<p><strong>BookKeepro System</strong></p>
"""
for admin_email in admin_emails:
asyncio.run(
send_email(
# Email to all admins
admin_body = f"""
<p>Admin Notice:</p>
<p>The <strong>{doc_label} filing deadline</strong> for client
<strong>{user.name or user.email}</strong> ({user.email}) is in
<strong>{label}</strong> ({dl.deadline_date.strftime('%B %d, %Y')}).</p>
<p>Please review the client's status and take any necessary action.</p>
<p><strong>BookKeepro System</strong></p>
"""
for admin_email in admin_emails:
await send_email(
to=admin_email,
subject=f"Admin Reminder: {user.email} — {doc_label} Deadline in {label}",
body=admin_body,
)
# Mark as notified
setattr(dl, flag_col, True)
db.commit()
logger.info(
"Sent %s deadline reminder for user %s (%s)",
label, dl.user_id, dl.doc_type,
)
# Mark as notified
setattr(dl, flag_col, True)
db.commit()
logger.info(
"Sent %s deadline reminder for user %s (%s)",
label, dl.user_id, dl.doc_type,
)
asyncio.run(_dispatch_reminders())
except Exception as exc:
logger.error("Deadline reminder job failed: %s", exc)
finally:
+8
View File
@@ -0,0 +1,8 @@
from app.db import SessionLocal
from app.models import User
db = SessionLocal()
users = db.query(User).filter(User.email.ilike("%%atharva%%")).all()
for u in users:
print(f"ID: {u.id}, Email: '{u.email}'")
db.close()
+2 -2
View File
@@ -42,5 +42,5 @@ pypdf==4.3.1
chromadb==0.5.5
openpyxl
APScheduler
openpyxl==3.1.5
APScheduler==3.11.3
+17
View File
@@ -0,0 +1,17 @@
from app.database import SessionLocal
from app.models import User
from app.crud import get_password_hash
db = SessionLocal()
email = "atharvagunjarge5@gmail.com".lower()
user = db.query(User).filter(User.email == email).first()
if user:
new_password = "Gunjarge@1705"
user.hashed_password = get_password_hash(new_password)
db.commit()
print("Password updated successfully!")
else:
print("User not found in database!")
db.close()
+17
View File
@@ -0,0 +1,17 @@
from app.db import SessionLocal
from app.models import User
from app.crud import get_password_hash
db = SessionLocal()
email = "atharvagunjarge5@gmail.com".lower()
user = db.query(User).filter(User.email == email).first()
if user:
new_password = "Gunjarge@1705"
user.hashed_password = get_password_hash(new_password)
db.commit()
print("Password updated successfully!")
else:
print("User not found in database!")
db.close()
+22
View File
@@ -0,0 +1,22 @@
from app.db import SessionLocal
from app.models import User
from passlib.context import CryptContext
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def get_password_hash(password: str):
return pwd_context.hash(password)
db = SessionLocal()
email = "atharvagunjarge5@gmail.com".lower()
user = db.query(User).filter(User.email == email).first()
if user:
new_password = "Gunjarge@1705"
user.hashed_password = get_password_hash(new_password)
db.commit()
print("Password updated successfully!")
else:
print("User not found in database!")
db.close()
+19 -2
View File
@@ -1,5 +1,17 @@
import os
import sys
from pathlib import Path
from dotenv import load_dotenv
# Try loading .env from repo root or current directory
for env_candidate in [
Path(__file__).resolve().parents[2] / ".env",
Path(__file__).resolve().parent / ".env",
Path(".env")
]:
if env_candidate.is_file():
load_dotenv(env_candidate)
break
REQUIRED_VARS = [
"MYSQL_USER",
@@ -12,11 +24,16 @@ REQUIRED_VARS = [
def main():
missing = []
placeholder_values = {
"your_password", "your_password_here", "password", "secret",
"your_secret_key", "changeme", "change_me", "placeholder",
"your_api_key_here", "example", "admin"
}
for var in REQUIRED_VARS:
val = os.getenv(var)
if not val:
if not val or not val.strip():
missing.append(var)
elif "password" in val.lower() or "secret" in val.lower() or "your" in val.lower() or "here" in val.lower():
elif val.lower().strip() in placeholder_values or val.lower().startswith("your_") or val.lower().endswith("_here"):
if var in ["SECRET_KEY", "MYSQL_PASSWORD"]:
missing.append(f"{var} (looks like a placeholder)")
else: