def validateSignup(**raw): """Validates the signup form input Validates the input from the signup form using the regex defined in settings Args: **raw: Collects all the named arguments Returns: A tuple containing: - Boolean: Whether there was an error or not - dict(): Containing the original params and the generated error params """ error = False params = { 'username': raw['username'], 'email': raw['email'] } if not utils.validateUsername(raw['username']): params['error_username'] = settings.RE_USERNAME_FAIL error = True if not utils.validatePassword(raw['password']): params['error_password'] = settings.RE_PASSWORD_FAIL error = True elif raw['password'] != raw['verify']: params['error_verify'] = settings.RE_PASSWORD_MATCH error = True if not utils.validateEmail(raw['email']): params['error_email'] = settings.RE_EMAIL_FAIL error = True return (error, params)
def validateLogin(**raw): """Validates the login form input Validates the input from the login form using the regex defined in settings Args: **raw: Collects all the named arguments Returns: A tuple containing: - Boolean: Whether there was an error or not - dict(): Containing the original params and the generated error params """ error = False params = { 'username': raw['username'], 'password': raw['password'] } if not utils.validateUsername(raw['username']): params['error_username'] = settings.RE_USERNAME_FAIL error = True if not raw['password']: params['error_password'] = settings.RE_PASSWORD_EMPTY error = True return (error, params)