Skip to content

Commit

Permalink
fix #39 feat: make the configuration of password change work
Browse files Browse the repository at this point in the history
  • Loading branch information
daichen-daisy committed Jul 17, 2023
1 parent 3652b1b commit e971cb4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions freeauth-admin/src/freeauth/admin/auth/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ async def sign_up_with_code(
mobile=body.account if code_type == FreeauthCodeType.SMS else None,
email=body.account if code_type == FreeauthCodeType.EMAIL else None,
hashed_password=get_password_hash(password),
reset_pwd_on_next_login=settings.change_pwd_after_first_login_enabled,
client_info=client_info,
)
token = await auth_app.create_access_token(response, user.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ async def dependency(
raise HTTPException(
status_code=HTTPStatus.UNAUTHORIZED,
detail=dict(
reset_pwd_on_next_login="首次登录之前请更改密码"
reset_pwd_on_next_login="首次登录时需重新设置密码"
),
)

Expand Down
1 change: 1 addition & 0 deletions freeauth-ext/fastapi-ext/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async def user_sign_up(
mobile=faker.phone_number(),
email=faker.email(),
hashed_password="",
reset_pwd_on_next_login=False,
client_info=ci,
)
token = await auth_app.create_access_token(response, user.id)
Expand Down
6 changes: 5 additions & 1 deletion src/freeauth/db/auth/auth_qry_async_edgeql.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ async def sign_up(
email: str | None = None,
mobile: str | None = None,
hashed_password: str,
reset_pwd_on_next_login: bool,
client_info: str,
) -> SignInResult:
return await executor.query_single(
Expand All @@ -599,6 +600,7 @@ async def sign_up(
email := <optional str>$email,
mobile := <optional str>$mobile,
hashed_password := <str>$hashed_password,
reset_pwd_on_next_login := <bool>$reset_pwd_on_next_login,
client_info := (
<tuple<client_ip: str, user_agent: json>><json>$client_info
),
Expand All @@ -608,7 +610,8 @@ async def sign_up(
username := username,
email := email,
mobile := mobile,
hashed_password := hashed_password
hashed_password := hashed_password,
reset_pwd_on_next_login := reset_pwd_on_next_login
}
),
audit_log := (
Expand Down Expand Up @@ -643,6 +646,7 @@ async def sign_up(
email=email,
mobile=mobile,
hashed_password=hashed_password,
reset_pwd_on_next_login=reset_pwd_on_next_login,
client_info=client_info,
)

Expand Down
6 changes: 5 additions & 1 deletion src/freeauth/db/auth/auth_qry_edgeql.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ def sign_up(
email: str | None = None,
mobile: str | None = None,
hashed_password: str,
reset_pwd_on_next_login: bool,
client_info: str,
) -> SignInResult:
return executor.query_single(
Expand All @@ -599,6 +600,7 @@ def sign_up(
email := <optional str>$email,
mobile := <optional str>$mobile,
hashed_password := <str>$hashed_password,
reset_pwd_on_next_login := <bool>$reset_pwd_on_next_login,
client_info := (
<tuple<client_ip: str, user_agent: json>><json>$client_info
),
Expand All @@ -608,7 +610,8 @@ def sign_up(
username := username,
email := email,
mobile := mobile,
hashed_password := hashed_password
hashed_password := hashed_password,
reset_pwd_on_next_login := reset_pwd_on_next_login
}
),
audit_log := (
Expand Down Expand Up @@ -643,6 +646,7 @@ def sign_up(
email=email,
mobile=mobile,
hashed_password=hashed_password,
reset_pwd_on_next_login=reset_pwd_on_next_login,
client_info=client_info,
)

Expand Down
4 changes: 3 additions & 1 deletion src/freeauth/db/auth/queries/sign_up.edgeql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ with
email := <optional str>$email,
mobile := <optional str>$mobile,
hashed_password := <str>$hashed_password,
reset_pwd_on_next_login := <bool>$reset_pwd_on_next_login,
client_info := (
<tuple<client_ip: str, user_agent: json>><json>$client_info
),
Expand All @@ -14,7 +15,8 @@ with
username := username,
email := email,
mobile := mobile,
hashed_password := hashed_password
hashed_password := hashed_password,
reset_pwd_on_next_login := reset_pwd_on_next_login
}
),
audit_log := (
Expand Down

0 comments on commit e971cb4

Please sign in to comment.