Ejemplo n.º 1
0
    def submit(self, login=None, mail=None, password1=None, password2=None):

        user = cherrypy.request.user

        if mail == '':
            mail = None

        if password1 == '':
            password1 = None

        if password2 == '':
            password2 = None

        if mail is not None and user.mail != mail:
            user.mail = mail
            messages_service.success('Your mail was changed.')

        if password1 is not None and password2 is not None:
            if password1 != password2:
                messages_service.warning('The passwords do not match.')
            else:
                user.password = hash_password(password1, user.salt)
                messages_service.success('Your password was changed.')

        raise HTTPRedirect('/settings')
Ejemplo n.º 2
0
    def _validate_user_params(login=None, mail=None, roles=None, password1=None, password2=None):
        if login is None or len(login) < 3:
            messages_service.warning('Login must be at least 3 chars.')
            raise cherrypy.HTTPError(status=409)

        if mail is None or len(mail) < 3:
            messages_service.warning('Mail must be at least 3 chars.')
            raise cherrypy.HTTPError(status=409)
            return

        if password1 is not None and password2 is not None:
            if password1 != password2:
                messages_service.warning('The passwords do not match.')
                raise cherrypy.HTTPError(status=409)