Skip to content

Commit 747352b

Browse files
Org creation now works correctly! :-O
1 parent a373df7 commit 747352b

File tree

6 files changed

+10
-17
lines changed

6 files changed

+10
-17
lines changed

main.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,6 @@ async def read_reset_password(
228228

229229
# Define a dependency for common parameters
230230
async def common_authenticated_parameters(
231-
request: Request,
232-
user: User = Depends(get_authenticated_user),
233-
error_message: Optional[str] = None,
234-
) -> dict:
235-
return {"request": request, "user": user, "error_message": error_message}
236-
237-
238-
async def common_authenticated_parameters_with_organizations(
239231
request: Request,
240232
user: User = Depends(get_user_with_relations),
241233
error_message: Optional[str] = None
@@ -253,9 +245,8 @@ async def read_dashboard(
253245

254246
@app.get("/profile")
255247
async def read_profile(
256-
params: dict = Depends(common_authenticated_parameters_with_organizations)
248+
params: dict = Depends(common_authenticated_parameters)
257249
):
258-
params["organizations"] = params["user"].organizations
259250
return templates.TemplateResponse(params["request"], "users/profile.html", params)
260251

261252

routers/authentication.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class UserRead(BaseModel):
119119
# -- Routes --
120120

121121

122+
# TODO: Use custom error message in the case where the user is already registered
122123
@router.post("/register", response_class=RedirectResponse)
123124
async def register(
124125
user: UserRegister = Depends(UserRegister.as_form),

routers/organization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def as_form(cls, id: int = Form(...), name: str = Form(...)):
9393

9494
# -- Routes --
9595

96-
@router.post("/", response_class=RedirectResponse)
96+
@router.post("/create", name="create_organization", response_class=RedirectResponse)
9797
def create_organization(
9898
org: OrganizationCreate = Depends(OrganizationCreate.as_form),
9999
user: User = Depends(get_authenticated_user),
@@ -132,7 +132,7 @@ def create_organization(
132132
return RedirectResponse(url=f"/profile", status_code=303)
133133

134134

135-
@router.put("/{org_id}", response_class=RedirectResponse)
135+
@router.post("/update/{org_id}", name="update_organization", response_class=RedirectResponse)
136136
def update_organization(
137137
org: OrganizationUpdate = Depends(OrganizationUpdate.as_form),
138138
user: User = Depends(get_user_with_relations),
@@ -162,7 +162,7 @@ def update_organization(
162162
return RedirectResponse(url=f"/profile", status_code=303)
163163

164164

165-
@router.delete("/{org_id}", response_class=RedirectResponse)
165+
@router.post("/delete/{org_id}", name="delete_organization", response_class=RedirectResponse)
166166
def delete_organization(
167167
org_id: int,
168168
user: User = Depends(get_user_with_relations),

templates/authentication/register.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<!-- Password Input -->
2525
<div class="mb-3">
2626
<label for="password" class="form-label">Password</label>
27+
<!-- Make sure 9g,X*88w[6"W passes validation -->
2728
<input type="password" class="form-control" id="password" name="password"
2829
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*?&\{\}\<\>\.\,\\\\'#\-_=\+\(\)\[\]:;\|~\/])[A-Za-z\d@$!%*?&\{\}\<\>\.\,\\\\'#\-_=\+\(\)\[\]:;\|~\/]{8,}"
2930
title="Must contain at least one number, one uppercase and lowercase letter, one special character, and at least 8 or more characters"

templates/components/organizations.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="card-body">
1010
<!-- New Organization Form -->
1111
<div class="collapse mb-3" id="newOrgForm">
12-
<form action="/organizations/" method="post" class="border rounded p-3 bg-light">
12+
<form action="/organizations/create" method="post" class="border rounded p-3 bg-light">
1313
<div class="mb-3">
1414
<label for="name" class="form-label">Organization Name</label>
1515
<input type="text"

templates/users/profile.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ <h1 class="mb-4">User Profile</h1>
5959
Change Password
6060
</div>
6161
<div class="card-body">
62-
<!-- Trigger password reset via email confirmation -->
62+
<!-- TODO: Trigger password reset via email confirmation -->
6363
<form action="{{ url_for('forgot_password') }}" method="post">
6464
<input type="hidden" name="email" value="{{ user.email }}">
6565
<p>To change your password, please confirm your email. A password reset link will be sent to your email address.</p>
@@ -68,8 +68,8 @@ <h1 class="mb-4">User Profile</h1>
6868
</div>
6969
</div>
7070

71-
<!-- Organizations Section - Add this before the Delete Account section -->
72-
{{ render_organizations(organizations) }}
71+
<!-- Organizations Section -->
72+
{{ render_organizations(user.roles|map(attribute='organization')|list) }}
7373

7474
<!-- Delete Account -->
7575
<div class="card mb-4">

0 commit comments

Comments
 (0)