crawlconfig: add 'name' property to crawl config
superuser init: don't check invite token for verified superuser (automatic init) fix formatting
This commit is contained in:
parent
c561fe3af4
commit
88f1689e0e
@ -78,6 +78,8 @@ class CrawlConfigIn(BaseModel):
|
||||
|
||||
config: RawCrawlConfig
|
||||
|
||||
name: Optional[str]
|
||||
|
||||
colls: Optional[List[str]] = []
|
||||
|
||||
crawlTimeout: Optional[int] = 0
|
||||
@ -92,6 +94,8 @@ class CrawlConfig(BaseMongoModel):
|
||||
|
||||
config: RawCrawlConfig
|
||||
|
||||
name: Optional[str]
|
||||
|
||||
colls: Optional[List[str]] = []
|
||||
|
||||
crawlTimeout: Optional[int] = 0
|
||||
|
@ -130,7 +130,7 @@ class InviteOps:
|
||||
created=datetime.utcnow(),
|
||||
role=invite.role if hasattr(invite, "role") else None,
|
||||
email=invite.email,
|
||||
inviterEmail=user.email
|
||||
inviterEmail=user.email,
|
||||
)
|
||||
|
||||
other_user = await user_manager.user_db.get_by_email(invite.email)
|
||||
|
@ -120,7 +120,12 @@ class UserManager(BaseUserManager[UserCreate, UserDB]):
|
||||
user.name = user.name or user.email
|
||||
|
||||
# if open registration not enabled, can only register with an invite
|
||||
if not self.registration_enabled and not user.inviteToken:
|
||||
if (
|
||||
not self.registration_enabled
|
||||
and not user.inviteToken
|
||||
and not user.is_verified
|
||||
and not user.is_superuser
|
||||
):
|
||||
raise HTTPException(status_code=400, detail="Invite Token Required")
|
||||
|
||||
if user.inviteToken and not await self.invites.get_valid_invite(
|
||||
@ -226,14 +231,14 @@ class UserManager(BaseUserManager[UserCreate, UserDB]):
|
||||
result = invite.serialize()
|
||||
result["inviterName"] = inviter.name
|
||||
if invite.aid:
|
||||
archive = await self.archive_ops.get_archive_for_user_by_id(invite.aid, inviter)
|
||||
archive = await self.archive_ops.get_archive_for_user_by_id(
|
||||
invite.aid, inviter
|
||||
)
|
||||
result["archiveName"] = archive.name
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
|
||||
# ============================================================================
|
||||
def init_user_manager(mdb, emailsender, invites):
|
||||
"""
|
||||
@ -323,8 +328,9 @@ def init_users_api(app, user_manager):
|
||||
return await user_manager.format_invite(invite)
|
||||
|
||||
@users_router.get("/me/invite/{token}", tags=["invites"])
|
||||
async def get_existing_user_invite_info(token: str,
|
||||
user: User = Depends(current_active_user)):
|
||||
async def get_existing_user_invite_info(
|
||||
token: str, user: User = Depends(current_active_user)
|
||||
):
|
||||
|
||||
try:
|
||||
invite = user.invites[token]
|
||||
@ -334,7 +340,6 @@ def init_users_api(app, user_manager):
|
||||
|
||||
return await user_manager.format_invite(invite)
|
||||
|
||||
|
||||
app.include_router(users_router, prefix="/users", tags=["users"])
|
||||
|
||||
asyncio.create_task(user_manager.create_super_user())
|
||||
|
Loading…
Reference in New Issue
Block a user