Пример #1
0
    def community_teamkey_update(self, request):
        if not is_auth_user_admin(headers=self.request_state.headers):
            return ResponseMessage(success=False)

        Community.update_teamkey(request)
        new_user_team_token = update_user_team_token(headers=self.request_state.headers, team_key=request.new_team_key)
        return ResponseMessage(success=True, msg=json.dumps(new_user_team_token))
Пример #2
0
    def update_user(self, request):
        action_auth_user = auth_user(self.request_state.headers)
        if not (action_auth_user.user_email == request.user_email):
            if not is_auth_user_admin(action_auth_user=action_auth_user):
                return ResponseMessage(success=False)

        user = get_user_from_request(user_id=request.user_id,
                                     user_email=request.user_email,
                                     team_key=request.team_key)

        if user:
            user.display_name = request.user_display_name or user.display_name
            user.password = md5(request.user_password) if request.user_password else user.password
            user.image_url = request.user_image_url or user.image_url or ""
            user.put()

        community = Community.getCommunityFromTeamKey(request.team_key) if request.team_key else Community.get_by_id(request.community_id)

        resp = None
        if user and community:
            circle = 0
            for circle_value, circle_name in community.circles.iteritems():
                if circle_name == request.circle:
                    circle = int(circle_value)

            resp = UserRole.edit(user, community, request.role, circle)

        return ResponseMessage(success=True if resp else False)
Пример #3
0
    def reset_team_secret(self, request):
        if not is_auth_user_admin(headers=self.request_state.headers):
            return CommunityValueMessage(secret=None)

        secret = Community.reset_team_secret(request.team_key)
        new_user_team_token = update_user_team_token(headers=self.request_state.headers, team_secret=secret)
        return CommunityValueMessage(secret=secret, user_team_token=json.dumps(new_user_team_token))
Пример #4
0
    def insert_user(self, request):
        if not is_auth_user_admin(headers=self.request_state.headers):
            return ResponseMessage(success=False)

        action_user = auth_user(self.request_state.headers)
        user = get_user_from_request(user_id=request.user_id,
                                     user_email=request.user_email,
                                     team_key=request.team_key)

        if not user:
            user = User.insert_user(request.user_email,
                                    username=request.user_display_name,
                                    account_type=request.team_key,
                                    auth_source=AuthSourceType.PLUGIN,
                                    password=md5(request.user_password),
                                    image_url=request.user_image_url or "")

        community = Community.getCommunityFromTeamKey(request.team_key) if request.team_key else Community.get_by_id(request.community_id)
        role = request.role if request.role else UserRoleType.MEMBER

        resp = None
        if user and community:
            circle = 0
            for circle_value, circle_name in community.circles.iteritems():
                if circle_name == request.circle:
                    circle = int(circle_value)

            resp = UserRole.insert(user, community, role, circle)
            send_added_user_email(community.name, user.display_name, "added", action_user.display_name, community.team_hash)

        return ResponseMessage(success=True if resp else False)
Пример #5
0
    def community_update(self, request):
        if not is_auth_user_admin(headers=self.request_state.headers):
            return ResponseMessage(success=False)

        Community.update(request)
        return ResponseMessage(success=True)