Beispiel #1
0
    def get(self, username):
        """ launch build  from gitlab webhook"""
        access_token = pecan.request.GET.get('access_token')
        if access_token:
            # Check if this user exists in DB
            user = User.fetch(username)
            if user is None:
                # This user maybe a group
                data = gitlab.get_group(username, access_token)
                if data is not None:
                    url = "%s/groups/%s" % (pecan.conf.gitlab_url,
                                            data['name'])
                    if pecan.conf.gitlab_secure:
                        url = "https://"
                    else:
                        url = "http://"
                    # Save this new group
                    user = User({
                        "username": data['name'],
                        "name": data['name'],
                        "gitlab_url": url,
                        "gitlab_group": True,
                        "id_gitlab": data['id'],
                    })
                if not user.create():
                    return None
                else:
                    # if user doesn't exists and this is not a group
                    # This request is strange so 403
                    abort(403)
            else:
                # if not we need to create it
                gitlab_user = gitlab.get_user(user.id_gitlab, access_token)
                # Update user info
                # TODO Disabled for now


#                if gitlab_user:
#                    user.name = gitlab_user.get('name')
#                    user.email = gitlab_user.get('email')
#                    if not user.update():
#                        return None
            if user.gitlab_group:
                return gitlab.update_group_info_from_gitlab(user, access_token)
            else:
                return gitlab.update_user_info_from_gitlab(
                    username, access_token)
        return None
Beispiel #2
0
    def get(self, username):
        """ launch build  from gitlab webhook"""
        access_token = pecan.request.GET.get('access_token')
        if access_token:
            # Check if this user exists in DB
            user = User.fetch(username)
            if user is None:
                # This user maybe a group
                data = gitlab.get_group(username, access_token)
                if data is not None:
                    url = "%s/groups/%s" % (pecan.conf.gitlab_url,
                                            data['name'])
                    if pecan.conf.gitlab_secure:
                        url = "https://"
                    else:
                        url = "http://"
                    # Save this new group
                    user = User({"username": data['name'],
                                 "name": data['name'],
                                 "gitlab_url": url,
                                 "gitlab_group": True,
                                 "id_gitlab": data['id'],
                                 })
                if not user.create():
                    return None
                else:
                    # if user doesn't exists and this is not a group
                    # This request is strange so 403
                    abort(403)
            else:
                # if not we need to create it
                gitlab_user = gitlab.get_user(user.id_gitlab, access_token)
                # Update user info
                # TODO Disabled for now
#                if gitlab_user:
#                    user.name = gitlab_user.get('name')
#                    user.email = gitlab_user.get('email')
#                    if not user.update():
#                        return None
            if user.gitlab_group:
                return gitlab.update_group_info_from_gitlab(user, access_token)
            else:
                return gitlab.update_user_info_from_gitlab(username, access_token)
        return None
Beispiel #3
0
 def get(self, username):
     access_token = pecan.request.GET.get('access_token')
     if access_token:
         gitlab.update_user_info_from_gitlab(username, access_token)
     return None
Beispiel #4
0
 def get(self, username):
     access_token = pecan.request.GET.get('access_token')
     if access_token:
         gitlab.update_user_info_from_gitlab(username, access_token)
     return None