

@tornado.gen.coroutine
def post(self):
    name = self.get_argument('name', '')
    name = unicodedata.normalize('NFKC', name)
    name = tornado.escape.squeeze(name.strip())
    email = self.get_argument('email', '')
    email = unicodedata.normalize('NFKC', email)
    email = tornado.escape.squeeze(email.strip())
    password = self.get_argument('password', '')
    password = unicodedata.normalize('NFKC', password)
    password = password.encode()
    password2 = self.get_argument('password2', '')
    password2 = unicodedata.normalize('NFKC', password2)
    password2 = password2.encode()
    locked = (yield self.get_config_key('noregistration'))
    formerror = None
    formfocus = 'name'
    if locked:
        formerror = 'Player registration is not allowed at this time.'
    elif (not name):
        formerror = 'You must enter your player name.'
        formfocus = 'name'
    elif ('@' in name):
        formerror = 'Your player name may not contain the @ sign.'
        formfocus = 'name'
    elif (len(name) > 32):
        formerror = 'Your name is limited to 32 characters.'
        formfocus = 'name'
    elif (not email):
        formerror = 'You must enter an email address.'
        formfocus = 'email'
    elif ('@' not in email):
        formerror = 'Your email address must contain an @ sign.'
        formfocus = 'email'
    elif (len(email) > 128):
        formerror = 'Your email address is limited to 128 characters.'
        formfocus = 'email'
    elif (not password):
        formerror = 'You must enter your password.'
        formfocus = 'password'
    elif (not password2):
        formerror = 'You must enter your password twice.'
        formfocus = 'password2'
    elif (len(password) < 6):
        formerror = 'Please use at least six characters in your password.'
        formfocus = 'password'
    elif (len(password) > 128):
        formerror = 'Please use no more than 128 characters in your password.'
        formfocus = 'password'
    elif (password != password2):
        formerror = 'The passwords you entered were not the same.'
        password2 = ''
        formfocus = 'password2'
    if formerror:
        self.render('register.html', formerror=formerror, formfocus=formfocus, init_name=name, init_email=email, init_password=password, init_password2=password2)
        return
    try:
        res = (yield self.application.twsessionmgr.create_player(self, email, name, password))
        self.application.twlog.info('Player created: %s (session %s)', email, res)
    except MessageException as ex:
        formerror = str(ex)
        self.render('register.html', formerror=formerror, formfocus=formfocus, init_name=name, init_email=email, init_password=password, init_password2=password2)
        return
    self.set_cookie('tworld_name', tornado.escape.url_escape(name), expires_days=30)
    self.redirect('/play')

dataset/ETHPy150Open erkyrath/tworld/lib/tweblib/handlers.py RegisterHandler.post/original