Esempio n. 1
0
def register(**kwargs):
    """
    Method turns keyword arguments (which describe user) into a dictionary and registers the user by \c XMLRPC and
    """
    if ('recaptcha' in kwargs):
        kwargs.pop('recaptcha')
    kwargs['wi_data'] = settings.WI_DATA
    return make_request('guest/user/register/', kwargs)
Esempio n. 2
0
def authenticate(username, password):
    """
    Method for authentication. When successful, it returns \c user object.
    """
    response = make_request('guest/user/check_password/', {'login': username, 'password': password})
    if response['status'] == 'ok' and response['data']:
        return parse_user(response['data'])
    return None
Esempio n. 3
0
def register(**kwargs):
    """
    Method turns keyword arguments (which describe user) into a dictionary and registers the user by \c XMLRPC and
    """
    if ('recaptcha' in kwargs):
        kwargs.pop('recaptcha')
    kwargs['wi_data'] = settings.WI_DATA
    return make_request('guest/user/register/', kwargs)
Esempio n. 4
0
def activate(activation_key):
    """
    Method checks, if \c activation_key is ok. If so, it activates user.
    """
    if SHA1_RE.search(activation_key):
        response = make_request('guest/user/activate/', {'act_key': activation_key, 'wi_data': settings.WI_DATA})
        if response['status'] == 'ok':
            return response
    return False
Esempio n. 5
0
File: user.py Progetto: pojoba02/cc1
    def clean_login(self):
        """
        Validate that the login is alphanumeric and is not already in use.
        """
        response = make_request("guest/user/exists/", {"login": self.cleaned_data["login"]})

        if response["data"] == False:
            return self.cleaned_data["login"]
        else:
            raise forms.ValidationError(_("A user with that login already exists."))
Esempio n. 6
0
    def clean_email(self):
        """
        Validate that the supplied email address is unique for the site.
        """
        response = make_request('guest/user/email_exists/', {'email': self.cleaned_data['email']})

        if response['data'] == False:
            return self.cleaned_data['email']
        else:
            raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
Esempio n. 7
0
    def clean_login(self):
        """
        Validate that the login is alphanumeric and is not already in use.
        """
        response = make_request('guest/user/exists/', {'login': self.cleaned_data['login']})

        if response['data'] == False:
            return self.cleaned_data['login']
        else:
            raise forms.ValidationError(_("A user with that login already exists."))
Esempio n. 8
0
    def clean_email(self):
        """
        Validate that the supplied email address is unique for the site.
        """
        response = make_request('guest/user/email_exists/', {'email': self.cleaned_data['email']})

        if response['data'] == False:
            return self.cleaned_data['email']
        else:
            raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
Esempio n. 9
0
def cm_authenticate(user, password, cm_id):
    """
    CM admin authentication. Returns True if successful.

    @parameter{user}
    @parameter{password}
    @parameter{cm_id}
    """
    rest_data = make_request('user/admin/check_password/', {'cm_password': password}, user=user)
    return True if rest_data['status'] == 'ok' else False
Esempio n. 10
0
File: user.py Progetto: pojoba02/cc1
    def clean_email(self):
        """
        Validates that a user exists with the given e-mail address.
        """
        email = self.cleaned_data["email"]

        rest_data = make_request("guest/user/email_exists/", {"email": email})
        if rest_data["status"] == "ok" and rest_data["data"] == False:
            raise forms.ValidationError(_("Incorrect email address."))

        return email
Esempio n. 11
0
    def clean_old_password(self):
        """
        Validates that the old_password field is correct.
        """
        self.cleaned_data['old_password'] = hashlib.sha1(self.cleaned_data['old_password']).hexdigest()
        old_password = self.cleaned_data["old_password"]

        rest_data = make_request('guest/user/check_password/', {'login': self.user.username, 'password': old_password})
        if rest_data['status'] == 'ok' and rest_data['data'] == False:
            raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again."))
        return old_password
Esempio n. 12
0
    def clean_email(self):
        """
        Validates that a user exists with the given e-mail address.
        """
        email = self.cleaned_data['email']

        rest_data = make_request('guest/user/email_exists/', {'email': email})
        if rest_data['status'] == 'ok' and rest_data['data'] == False:
            raise forms.ValidationError(_('Incorrect email address.'))

        return email
Esempio n. 13
0
    def clean_old_password(self):
        """
        Validates that the old_password field is correct.
        """
        self.cleaned_data['old_password'] = hashlib.sha1(self.cleaned_data['old_password']).hexdigest()
        old_password = self.cleaned_data["old_password"]

        rest_data = make_request('guest/user/check_password/', {'login': self.user.username, 'password': old_password})
        if rest_data['status'] == 'ok' and rest_data['data'] == False:
            raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again."))
        return old_password
Esempio n. 14
0
    def clean_email(self):
        """
        Validates that a user exists with the given e-mail address.
        """
        email = self.cleaned_data['email']

        rest_data = make_request('guest/user/email_exists/', {'email': email})
        if rest_data['status'] == 'ok' and rest_data['data'] == False:
            raise forms.ValidationError(_('Incorrect email address.'))

        return email
Esempio n. 15
0
File: user.py Progetto: pojoba02/cc1
    def clean_old_password(self):
        """
        Validates that the old_password field is correct.
        """
        self.cleaned_data["old_password"] = hashlib.sha1(self.cleaned_data["old_password"]).hexdigest()
        old_password = self.cleaned_data["old_password"]

        rest_data = make_request("guest/user/check_password/", {"login": self.user.username, "password": old_password})
        if rest_data["status"] == "ok" and rest_data["data"] == False:
            raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again."))
        return old_password
Esempio n. 16
0
def authenticate(username, password):
    """
    Method for authentication. When successful, it returns \c user object.
    """
    response = make_request('guest/user/check_password/', {
        'login': username,
        'password': password
    })
    if response['status'] == 'ok' and response['data']:
        return parse_user(response['data'])
    return None
Esempio n. 17
0
def activate(activation_key):
    """
    Method checks, if \c activation_key is ok. If so, it activates user.
    """
    if SHA1_RE.search(activation_key):
        response = make_request('guest/user/activate/', {
            'act_key': activation_key,
            'wi_data': settings.WI_DATA
        })
        if response['status'] == 'ok':
            return response
    return False
Esempio n. 18
0
def cm_authenticate(user, password, cm_id):
    """
    CM admin authentication. Returns True if successful.

    @parameter{user}
    @parameter{password}
    @parameter{cm_id}
    """
    rest_data = make_request('user/admin/check_password/',
                             {'cm_password': password},
                             user=user)
    return True if rest_data['status'] == 'ok' else False
Esempio n. 19
0
    def clean_email(self):
        """
        Validate that the supplied email address is unique for the site.
        """
        # if same email as current
        if self.old_email == self.cleaned_data['email']:
            return self.cleaned_data['email']

        rest_data = make_request('guest/user/email_exists/', {'email': self.cleaned_data['email']})

        if rest_data['data']:
            raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
        else:
            return self.cleaned_data['email']
Esempio n. 20
0
    def clean_email(self):
        """
        Validate that the supplied email address is unique for the site.
        """
        # if same email as current
        if self.old_email == self.cleaned_data['email']:
            return self.cleaned_data['email']

        rest_data = make_request('guest/user/email_exists/', {'email': self.cleaned_data['email']})

        if rest_data['data']:
            raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
        else:
            return self.cleaned_data['email']
Esempio n. 21
0
    def clean(self):
        """
        Checks if there is enough space on CM.
        """
        if not self.cleaned_data.get('count') or not self.cleaned_data.get('worker_template_id') or not self.cleaned_data.get('head_template_id'):
            return None

        response = make_request('user/farm/check_resources/',
                                {'count': self.cleaned_data.get('count'),
                                 'template_id': self.cleaned_data.get('worker_template_id'),
                                 'head_template_id': self.cleaned_data.get('head_template_id')
                                 }, user=self.session['user'])

        if response['status'] == 'ok' and response['data'] == False:
            raise forms.ValidationError(_("Not enough resources. Choose smaller farm or try again later."))
        else:
            return self.cleaned_data
Esempio n. 22
0
    def clean(self):
        """
        Checks if there is enough space on CM.
        """
        if not self.cleaned_data.get('count') or not self.cleaned_data.get(
                'worker_template_id') or not self.cleaned_data.get(
                    'head_template_id'):
            return None

        response = make_request(
            'user/farm/check_resources/', {
                'count': self.cleaned_data.get('count'),
                'template_id': self.cleaned_data.get('worker_template_id'),
                'head_template_id': self.cleaned_data.get('head_template_id')
            },
            user=self.session['user'])

        if response['status'] == 'ok' and response['data'] == False:
            raise forms.ValidationError(
                _("Not enough resources. Choose smaller farm or try again later."
                  ))
        else:
            return self.cleaned_data