Example #1
0
def user_registration(request):
    """
    Registers new user with data given in the ajax request.

    :param request: current request of the server
    :return: dict() with success and message
    """
    LOG.debug("Register new user via AJAX. %s", request.json_body)
    mailer = request.mailer
    lang = request.validated['lang']

    success, info, new_user = register_user_with_json_data(
        request.validated, lang, mailer)

    return {'success': str(success), 'error': '', 'info': str(info)}
Example #2
0
def user_registration(request):
    """
    Registers new user with data given in the ajax request.

    :param request: current request of the server
    :return: dict() with success and message
    """
    logger('Views', 'main: {}'.format(request.json_body))
    mailer = request.mailer
    lang = request.validated['lang']

    success, info, new_user = register_user_with_json_data(
        request.validated, lang, mailer)

    return {'success': str(success), 'error': '', 'info': str(info)}
Example #3
0
 def test_register_user_nickname_is_taken(self):
     request = construct_dummy_request(
         validated={
             'firstname': self.uustring(),
             'lastname': self.uustring(),
             'nickname': 'Tobias',
             'email': self.uustring() + '@hhu.de',
             'gender': 'm',
             'password': '******',
             'passwordconfirm': 'somepasswd',
             'mode': 'manually',
         })
     success, msg, db_new_user = register_user_with_json_data(
         request.validated, 'en', request.mailer)
     self.assertEqual(self._tn.get(_.nickIsTaken), msg)
     self.assertIsNone(db_new_user)
Example #4
0
 def test_login_register_with_json_data(self):
     request = construct_dummy_request(
         validated={
             'firstname': '',
             'lastname': '',
             'nickname': '',
             'email': ' ',
             'gender': '',
             'password': '',
             'passwordconfirm': '',
             'mode': '',
         })
     success, msg, db_new_user = register_user_with_json_data(
         request.validated, 'en', request.mailer)
     self.assertEqual(self._tn.get(_.checkFirstname), msg)
     self.assertIsNone(db_new_user)
Example #5
0
 def test_register_user_passwords_not_equal(self):
     request = construct_dummy_request(
         validated={
             'firstname': 'Bob',
             'lastname': 'Builder',
             'nickname': 'Builder',
             'email': '*****@*****.**',
             'gender': 'm',
             'password': self.uustring(),
             'passwordconfirm': self.uustring(),
             'mode': 'manually',
         })
     success, msg, db_new_user = register_user_with_json_data(
         request.validated, 'en', request.mailer)
     self.assertEqual(self._tn.get(_.pwdNotEqual), msg)
     self.assertIsNone(db_new_user)
Example #6
0
 def test_register_user_mail_invalid(self):
     request = construct_dummy_request(
         validated={
             'firstname': self.uustring(),
             'lastname': self.uustring(),
             'nickname': self.uustring(),
             'email': 'nota@validhost',
             'gender': 'm',
             'password': '******',
             'passwordconfirm': 'somepasswd',
             'mode': 'manually',
         })
     success, msg, db_new_user = register_user_with_json_data(
         request.validated, 'en', request.mailer)
     self.assertEqual(self._tn.get(_.mailNotValid), msg)
     self.assertIsNone(db_new_user)
Example #7
0
 def test_login_register_with_json_data(self):
     request = testing.DummyRequest(validated={
         'firstname': '',
         'lastname': '',
         'nickname': '',
         'email': ' ',
         'gender': '',
         'password': '',
         'passwordconfirm': '',
         'mode': '',
     },
                                    mailer=DummyMailer)
     success, msg, db_new_user = register_user_with_json_data(
         request.validated, 'en', request.mailer)
     self.assertEqual(self._tn.get(_.pwdShort), msg)
     self.assertIsNone(db_new_user)
Example #8
0
    def test_register_user_mail_is_taken(self):
        request = testing.DummyRequest(validated={
            'firstname': self.uustring(),
            'lastname': self.uustring(),
            'nickname': self.uustring(),
            'email': '*****@*****.**',
            'gender': 'm',
            'password': '******',
            'passwordconfirm': 'somepasswd',
            'mode': 'manually',
        },
                                       mailer=DummyMailer)
        success, msg, db_new_user = register_user_with_json_data(
            request.validated, 'en', request.mailer)

        self.assertEqual(self._tn.get(_.mailIsTaken), msg)
        self.assertIsNone(db_new_user)