Skip to content

Commit 1eb15c6

Browse files
Copilotnotfolder
andcommitted
コードレビュー指摘事項を修正(特殊文字パターン定数化、インポート順序、日時フォーマット)
Co-authored-by: notfolder <20558197+notfolder@users.noreply.github.com>
1 parent 541e390 commit 1eb15c6

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

user_config_api/app/auth/password_policy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from dataclasses import dataclass, field
1010
from typing import Any
1111

12+
# 特殊文字として許可する文字セット
13+
_SPECIAL_CHARS_PATTERN = r"[!@#$%^&*()_+\-=\[\]{};':\"\\|,.<>\/?]"
14+
1215

1316
@dataclass
1417
class PasswordPolicy:
@@ -101,7 +104,7 @@ def validate_password(password: str, policy: PasswordPolicy) -> tuple[bool, list
101104
errors.append("パスワードに数字を含めてください")
102105

103106
# 特殊文字チェック
104-
if policy.require_special and not re.search(r"[!@#$%^&*()_+\-=\[\]{};':\"\\|,.<>\/?]", password):
107+
if policy.require_special and not re.search(_SPECIAL_CHARS_PATTERN, password):
105108
errors.append("パスワードに特殊文字を含めてください")
106109

107110
return len(errors) == 0, errors

user_config_api/streamlit_custom/pages/00_force_change_password.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# 親ディレクトリをPythonパスに追加
1515
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
1616

17-
from app.config import get_password_auth_config
1817
from app.auth.password_policy import PasswordPolicy
18+
from app.config import get_password_auth_config
1919
from app.database import get_db_context
2020
from app.services.user_service import UserService
2121
from streamlit_custom.components.auth import show_logout_button

user_config_api/streamlit_custom/pages/03_personal_settings.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@
182182
# 最終パスワード更新日時の表示
183183
password_updated_at = user.get("password_updated_at")
184184
if password_updated_at:
185-
st.markdown(f"最終パスワード更新日時: **{password_updated_at}**")
185+
# datetimeオブジェクトの場合はフォーマット、文字列の場合はそのまま表示
186+
if hasattr(password_updated_at, "strftime"):
187+
formatted_dt = password_updated_at.strftime("%Y-%m-%d %H:%M:%S")
188+
else:
189+
formatted_dt = str(password_updated_at)
190+
st.markdown(f"最終パスワード更新日時: **{formatted_dt}**")
186191

187192
with st.form("change_password_form"):
188193
current_password = st.text_input(

0 commit comments

Comments
 (0)