Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions backend/app/api/routes/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
UpdatePassword,
User,
UserCreate,
UserCreateOpen,
UserOut,
UserRegister,
UsersOut,
UserUpdate,
UserUpdateMe,
Expand Down Expand Up @@ -122,8 +122,8 @@ def read_user_me(session: SessionDep, current_user: CurrentUser) -> Any:
return current_user


@router.post("/open", response_model=UserOut)
def create_user_open(session: SessionDep, user_in: UserCreateOpen) -> Any:
@router.post("/signup", response_model=UserOut)
def register_user(session: SessionDep, user_in: UserRegister) -> Any:
"""
Create new user without the need to be logged in.
"""
Expand All @@ -138,7 +138,7 @@ def create_user_open(session: SessionDep, user_in: UserCreateOpen) -> Any:
status_code=400,
detail="The user with this email already exists in the system",
)
user_create = UserCreate.from_orm(user_in)
user_create = UserCreate.model_validate(user_in)
user = crud.create_user(session=session, user_create=user_create)
return user

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UserCreate(UserBase):


# TODO replace email str with EmailStr when sqlmodel supports it
class UserCreateOpen(SQLModel):
class UserRegister(SQLModel):
email: str
password: str
full_name: str | None = None
Expand Down
12 changes: 6 additions & 6 deletions backend/app/tests/api/routes/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,14 @@ def test_update_password_me_same_password_error(
)


def test_create_user_open(client: TestClient) -> None:
def test_register_user(client: TestClient) -> None:
with patch("app.core.config.settings.USERS_OPEN_REGISTRATION", True):
username = random_email()
password = random_lower_string()
full_name = random_lower_string()
data = {"email": username, "password": password, "full_name": full_name}
r = client.post(
f"{settings.API_V1_STR}/users/open",
f"{settings.API_V1_STR}/users/signup",
json=data,
)
assert r.status_code == 200
Expand All @@ -279,14 +279,14 @@ def test_create_user_open(client: TestClient) -> None:
assert created_user["full_name"] == full_name


def test_create_user_open_forbidden_error(client: TestClient) -> None:
def test_register_user_forbidden_error(client: TestClient) -> None:
with patch("app.core.config.settings.USERS_OPEN_REGISTRATION", False):
username = random_email()
password = random_lower_string()
full_name = random_lower_string()
data = {"email": username, "password": password, "full_name": full_name}
r = client.post(
f"{settings.API_V1_STR}/users/open",
f"{settings.API_V1_STR}/users/signup",
json=data,
)
assert r.status_code == 403
Expand All @@ -295,7 +295,7 @@ def test_create_user_open_forbidden_error(client: TestClient) -> None:
)


def test_create_user_open_already_exists_error(client: TestClient) -> None:
def test_register_user_already_exists_error(client: TestClient) -> None:
with patch("app.core.config.settings.USERS_OPEN_REGISTRATION", True):
password = random_lower_string()
full_name = random_lower_string()
Expand All @@ -305,7 +305,7 @@ def test_create_user_open_already_exists_error(client: TestClient) -> None:
"full_name": full_name,
}
r = client.post(
f"{settings.API_V1_STR}/users/open",
f"{settings.API_V1_STR}/users/signup",
json=data,
)
assert r.status_code == 400
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export type { NewPassword } from './models/NewPassword';
export type { Token } from './models/Token';
export type { UpdatePassword } from './models/UpdatePassword';
export type { UserCreate } from './models/UserCreate';
export type { UserCreateOpen } from './models/UserCreateOpen';
export type { UserOut } from './models/UserOut';
export type { UserRegister } from './models/UserRegister';
export type { UsersOut } from './models/UsersOut';
export type { UserUpdate } from './models/UserUpdate';
export type { UserUpdateMe } from './models/UserUpdateMe';
Expand All @@ -36,8 +36,8 @@ export { $NewPassword } from './schemas/$NewPassword';
export { $Token } from './schemas/$Token';
export { $UpdatePassword } from './schemas/$UpdatePassword';
export { $UserCreate } from './schemas/$UserCreate';
export { $UserCreateOpen } from './schemas/$UserCreateOpen';
export { $UserOut } from './schemas/$UserOut';
export { $UserRegister } from './schemas/$UserRegister';
export { $UsersOut } from './schemas/$UsersOut';
export { $UserUpdate } from './schemas/$UserUpdate';
export { $UserUpdateMe } from './schemas/$UserUpdateMe';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* tslint:disable */
/* eslint-disable */

export type UserCreateOpen = {
export type UserRegister = {
email: string;
password: string;
full_name?: (string | null);
Expand Down
60 changes: 30 additions & 30 deletions frontend/src/client/schemas/$Body_login_login_access_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@
export const $Body_login_login_access_token = {
properties: {
grant_type: {
type: 'any-of',
contains: [{
type: 'string',
pattern: 'password',
}, {
type: 'null',
}],
},
type: 'any-of',
contains: [{
type: 'string',
pattern: 'password',
}, {
type: 'null',
}],
},
username: {
type: 'string',
isRequired: true,
},
type: 'string',
isRequired: true,
},
password: {
type: 'string',
isRequired: true,
},
type: 'string',
isRequired: true,
},
scope: {
type: 'string',
},
type: 'string',
},
client_id: {
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
client_secret: {
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
},
} as const;
10 changes: 5 additions & 5 deletions frontend/src/client/schemas/$HTTPValidationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export const $HTTPValidationError = {
properties: {
detail: {
type: 'array',
contains: {
type: 'ValidationError',
},
},
type: 'array',
contains: {
type: 'ValidationError',
},
},
},
} as const;
20 changes: 10 additions & 10 deletions frontend/src/client/schemas/$ItemCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
export const $ItemCreate = {
properties: {
title: {
type: 'string',
isRequired: true,
},
type: 'string',
isRequired: true,
},
description: {
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
},
} as const;
32 changes: 16 additions & 16 deletions frontend/src/client/schemas/$ItemOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
export const $ItemOut = {
properties: {
title: {
type: 'string',
isRequired: true,
},
type: 'string',
isRequired: true,
},
description: {
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
id: {
type: 'number',
isRequired: true,
},
type: 'number',
isRequired: true,
},
owner_id: {
type: 'number',
isRequired: true,
},
type: 'number',
isRequired: true,
},
},
} as const;
28 changes: 14 additions & 14 deletions frontend/src/client/schemas/$ItemUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
export const $ItemUpdate = {
properties: {
title: {
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
description: {
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
type: 'any-of',
contains: [{
type: 'string',
}, {
type: 'null',
}],
},
},
} as const;
18 changes: 9 additions & 9 deletions frontend/src/client/schemas/$ItemsOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
export const $ItemsOut = {
properties: {
data: {
type: 'array',
contains: {
type: 'ItemOut',
},
isRequired: true,
},
type: 'array',
contains: {
type: 'ItemOut',
},
isRequired: true,
},
count: {
type: 'number',
isRequired: true,
},
type: 'number',
isRequired: true,
},
},
} as const;
6 changes: 3 additions & 3 deletions frontend/src/client/schemas/$Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
export const $Message = {
properties: {
message: {
type: 'string',
isRequired: true,
},
type: 'string',
isRequired: true,
},
},
} as const;
12 changes: 6 additions & 6 deletions frontend/src/client/schemas/$NewPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
export const $NewPassword = {
properties: {
token: {
type: 'string',
isRequired: true,
},
type: 'string',
isRequired: true,
},
new_password: {
type: 'string',
isRequired: true,
},
type: 'string',
isRequired: true,
},
},
} as const;
10 changes: 5 additions & 5 deletions frontend/src/client/schemas/$Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
export const $Token = {
properties: {
access_token: {
type: 'string',
isRequired: true,
},
type: 'string',
isRequired: true,
},
token_type: {
type: 'string',
},
type: 'string',
},
},
} as const;
Loading