Skip to content

Commit f2c7c67

Browse files
authored
♻️ Restrict change user email (#5472)
1 parent 7d5f6ed commit f2c7c67

File tree

8 files changed

+45
-71
lines changed

8 files changed

+45
-71
lines changed

api/specs/web-server/_auth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ async def reset_password_allowed(code: str, _body: ResetPasswordConfirmation):
194194
"description": "unable to send confirmation email",
195195
},
196196
},
197+
# Disabled in https://github.com/ITISFoundation/osparc-simcore/pull/5472
198+
include_in_schema=False,
197199
)
198200
async def change_email(_body: ChangeEmailBody):
199201
"""logged in user changes email"""

services/payments/src/simcore_service_payments/services/notifier_email.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ async def _create_successful_payments_message(
220220
self, user_id: UserID, payment: PaymentTransaction
221221
) -> EmailMessage:
222222
data = await self._users_repo.get_notification_data(user_id, payment.payment_id)
223+
data_vendor = data.vendor or {}
223224

224225
# email for successful payment
225226
msg: EmailMessage = await _create_user_email(
@@ -237,7 +238,7 @@ async def _create_successful_payments_message(
237238
product=_ProductData(
238239
product_name=data.product_name,
239240
display_name=data.display_name,
240-
vendor_display_inline=f"{data.vendor.get('name', '')}. {data.vendor.get('address', '')}",
241+
vendor_display_inline=f"{data_vendor.get('name', '')}. {data_vendor.get('address', '')}",
241242
support_email=data.support_email,
242243
),
243244
)

services/web/server/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.38.0
1+
0.39.0

services/web/server/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.38.0
2+
current_version = 0.39.0
33
commit = True
44
message = services/webserver api version: {current_version} → {new_version}
55
tag = False

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ openapi: 3.0.2
22
info:
33
title: simcore-service-webserver
44
description: Main service with an interface (http-API & websockets) to the web front-end
5-
version: 0.38.0
5+
version: 0.39.0
66
servers:
77
- url: ''
88
description: webserver
@@ -344,38 +344,6 @@ paths:
344344
application/json:
345345
schema:
346346
$ref: '#/components/schemas/Envelope_Error_'
347-
/v0/auth/change-email:
348-
post:
349-
tags:
350-
- auth
351-
summary: Change Email
352-
description: logged in user changes email
353-
operationId: auth_change_email
354-
requestBody:
355-
content:
356-
application/json:
357-
schema:
358-
$ref: '#/components/schemas/ChangeEmailBody'
359-
required: true
360-
responses:
361-
'200':
362-
description: Successful Response
363-
content:
364-
application/json:
365-
schema:
366-
$ref: '#/components/schemas/Envelope_Log_'
367-
'401':
368-
description: unauthorized user. Login required
369-
content:
370-
application/json:
371-
schema:
372-
$ref: '#/components/schemas/Envelope_Error_'
373-
'503':
374-
description: unable to send confirmation email
375-
content:
376-
application/json:
377-
schema:
378-
$ref: '#/components/schemas/Envelope_Error_'
379347
/v0/auth/change-password:
380348
post:
381349
tags:
@@ -2925,7 +2893,7 @@ paths:
29252893
'403':
29262894
description: ProjectInvalidRightsError
29272895
'404':
2928-
description: ProjectNotFoundError, UserDefaultWalletNotFoundError
2896+
description: UserDefaultWalletNotFoundError, ProjectNotFoundError
29292897
'409':
29302898
description: ProjectTooManyProjectOpenedError
29312899
'422':
@@ -4686,12 +4654,13 @@ components:
46864654
46874655
phone: +1 123456789
46884656
company: EM Com
4689-
address: Infinite Loop. California
4657+
address: Infinite Loop
4658+
city: Washington
4659+
postalCode: '98001'
46904660
country: USA
46914661
application: Antenna_Design
4692-
description: Description of sometin
4662+
description: Description of something
46934663
hear: Search_Engine
4694-
message: I would love to use your tool
46954664
Activity:
46964665
title: Activity
46974666
required:
@@ -5004,17 +4973,6 @@ components:
50044973
type: object
50054974
additionalProperties:
50064975
$ref: '#/components/schemas/BootChoice'
5007-
ChangeEmailBody:
5008-
title: ChangeEmailBody
5009-
required:
5010-
- email
5011-
type: object
5012-
properties:
5013-
email:
5014-
title: Email
5015-
type: string
5016-
format: email
5017-
additionalProperties: false
50184976
ChangePasswordBody:
50194977
title: ChangePasswordBody
50204978
required:
@@ -9905,6 +9863,9 @@ components:
99059863
title: TaskProgress
99069864
type: object
99079865
properties:
9866+
task_id:
9867+
title: Task Id
9868+
type: string
99089869
message:
99099870
title: Message
99109871
type: string

services/web/server/src/simcore_service_webserver/login/handlers_change.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ class ChangeEmailBody(InputSchema):
136136
email: LowerCaseEmailStr
137137

138138

139-
@routes.post(f"/{API_VTAG}/auth/change-email", name="auth_change_email")
140-
@login_required
141139
async def submit_request_to_change_email(request: web.Request):
140+
# NOTE: This code have been intentially disabled in https://github.com/ITISFoundation/osparc-simcore/pull/5472
142141
db: AsyncpgStorage = get_plugin_storage(request.app)
143142
product: Product = get_current_product(request)
144143

services/web/server/tests/unit/with_dbs/03/login/test_login_change_email.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ def new_email(fake_user_email: str) -> str:
2222
return fake_user_email
2323

2424

25+
async def test_change_email_disabled(client: TestClient, new_email: str):
26+
assert client.app
27+
assert "auth_change_email" not in client.app.router
28+
29+
response = await client.post(
30+
"/v0/auth/change-email",
31+
json={"email": new_email},
32+
)
33+
await assert_status(response, status.HTTP_404_NOT_FOUND)
34+
35+
36+
@pytest.mark.xfail(reason="Change email has been disabled")
2537
async def test_unauthorized_to_change_email(client: TestClient, new_email: str):
2638
assert client.app
2739
url = client.app.router["auth_change_email"].url_for()
@@ -31,29 +43,29 @@ async def test_unauthorized_to_change_email(client: TestClient, new_email: str):
3143
"email": new_email,
3244
},
3345
)
34-
assert response.status == 401
3546
await assert_status(response, status.HTTP_401_UNAUTHORIZED)
3647

3748

49+
@pytest.mark.xfail(reason="Change email has been disabled")
3850
async def test_change_to_existing_email(client: TestClient):
3951
assert client.app
4052
url = client.app.router["auth_change_email"].url_for()
4153

42-
async with LoggedUser(client) as user:
43-
async with NewUser(app=client.app) as other:
44-
response = await client.post(
45-
f"{url}",
46-
json={
47-
"email": other["email"],
48-
},
49-
)
50-
await assert_status(
51-
response,
52-
status.HTTP_422_UNPROCESSABLE_ENTITY,
53-
"This email cannot be used",
54-
)
54+
async with LoggedUser(client), NewUser(app=client.app) as other:
55+
response = await client.post(
56+
f"{url}",
57+
json={
58+
"email": other["email"],
59+
},
60+
)
61+
await assert_status(
62+
response,
63+
status.HTTP_422_UNPROCESSABLE_ENTITY,
64+
"This email cannot be used",
65+
)
5566

5667

68+
@pytest.mark.xfail(reason="Change email has been disabled")
5769
async def test_change_and_confirm(
5870
client: TestClient,
5971
login_options: LoginOptions,
@@ -107,6 +119,5 @@ async def test_change_and_confirm(
107119
"password": user["raw_password"],
108120
},
109121
)
110-
payload = await response.json()
111122
assert response.url.path == login_url.path
112123
await assert_status(response, status.HTTP_200_OK, MSG_LOGGED_IN)

services/web/server/tests/unit/with_dbs/03/login/test_login_logout.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ async def test_logout(client: TestClient, db: AsyncpgStorage):
1313
assert client.app
1414

1515
logout_url = client.app.router["auth_logout"].url_for()
16-
protected_url = client.app.router["auth_change_email"].url_for()
16+
protected_url = client.app.router["get_my_profile"].url_for()
1717

1818
async with LoggedUser(client) as user:
1919

2020
# try to access protected page
21-
response = await client.post(f"{protected_url}", json={"email": user["email"]})
21+
response = await client.get(f"{protected_url}")
2222
assert response.url.path == protected_url.path
2323
await assert_status(response, status.HTTP_200_OK)
2424

@@ -28,7 +28,7 @@ async def test_logout(client: TestClient, db: AsyncpgStorage):
2828
await assert_status(response, status.HTTP_200_OK)
2929

3030
# and try again
31-
response = await client.post(f"{protected_url}")
31+
response = await client.get(f"{protected_url}")
3232
assert response.url.path == protected_url.path
3333
await assert_status(response, status.HTTP_401_UNAUTHORIZED)
3434

0 commit comments

Comments
 (0)