feat(auth): 支持企业微信重置密码
This commit is contained in:
1 parent
9bc4d1dd18
commit
6baeffba64
55 files changed
+2852
-546
No files matched your search
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
backend/scripts/sync_wecom_userid_by_employee_id.py
|
||||
|
||||
用途:从企业微信通讯录拉取成员,按工号(employee_id)回填本地 users.wecom_userid。
|
||||
依赖:app.create_app、wecom_directory_sync.sync_wecom_userids_from_directory。
|
||||
逻辑:运维 CLI;默认 dry-run,--apply 才写库。
|
||||
|
||||
Usage:
|
||||
cd backend
|
||||
python scripts/sync_wecom_userid_by_employee_id.py
|
||||
python scripts/sync_wecom_userid_by_employee_id.py --apply
|
||||
python scripts/sync_wecom_userid_by_employee_id.py --apply --department-id 1
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
BACKEND_ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(BACKEND_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(BACKEND_ROOT))
|
||||
|
||||
from app import create_app # noqa: E402
|
||||
from app.services.wecom_directory_sync import sync_wecom_userids_from_directory # noqa: E402
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""CLI 入口:解析参数并打印同步摘要 JSON。"""
|
||||
parser = argparse.ArgumentParser(description='Sync User.wecom_userid from WeCom directory by employee_id.')
|
||||
parser.add_argument('--apply', action='store_true', help='Persist changes (default: dry-run).')
|
||||
parser.add_argument('--department-id', type=int, default=None, help='Root department id (default: all departments).')
|
||||
args = parser.parse_args()
|
||||
|
||||
env = os.getenv('FLASK_ENV', 'production')
|
||||
app = create_app(env)
|
||||
with app.app_context():
|
||||
summary = sync_wecom_userids_from_directory(apply=args.apply, department_id=args.department_id)
|
||||
|
||||
print(json.dumps(summary, ensure_ascii=False, indent=2))
|
||||
if summary.get('conflicts'):
|
||||
print('\nConflicts detected; resolve manually before --apply.', file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user