Пример #1
0
 async def post(self, *, code: str = ''):
     join_settings = domain.get_join_settings(self.domain, self.now)
     if not join_settings:
         raise error.DomainJoinForbiddenError(self.domain_id)
     await self.ensure_user_not_member()
     if join_settings['method'] == constant.domain.JOIN_METHOD_CODE:
         if join_settings['code'] != code:
             raise error.InvalidJoinInvitationCodeError(self.domain_id)
     try:
         await domain.add_user_role(self.domain_id, self.user['_id'],
                                    join_settings['role'])
     except error.UserAlreadyDomainMemberError:
         raise error.DomainJoinAlreadyMemberError(
             self.domain_id, self.user['_id']) from None
     self.json_or_redirect(self.reverse_url('domain_main'))
Пример #2
0
 async def get(self, *, code: str = ''):
     join_settings = domain.get_join_settings(self.domain, self.now)
     if not join_settings:
         raise error.DomainJoinForbiddenError(self.domain_id)
     await self.ensure_user_not_member()
     self.render('domain_join.html', join_settings=join_settings, code=code)