

@tornado.gen.coroutine
def post(self):
    locked = (yield self.get_config_key('nologin'))
    if self.get_argument('register', None):
        self.redirect('/register')
        return
    if self.get_argument('guest', None):
        try:
            if locked:
                raise MessageException('Sign-ins are not allowed at this time.')
            (res, email) = (yield self.application.twsessionmgr.create_session_guest(self))
        except MessageException as ex:
            formerror = str(ex)
            self.render('main.html', formerror=formerror)
            return
        self.application.twlog.info('Player signed in as guest: %s (session %s)', email, res)
        self.redirect('/play')
        return
    name = self.get_argument('name', '')
    name = unicodedata.normalize('NFKC', name)
    name = tornado.escape.squeeze(name.strip())
    password = self.get_argument('password', '')
    password = unicodedata.normalize('NFKC', password)
    password = password.encode()
    formerror = None
    if (not name):
        formerror = 'You must enter your player name or email address.'
    elif (not password):
        formerror = 'You must enter your password.'
    if formerror:
        self.render('main.html', formerror=formerror, init_name=name)
        return
    try:
        res = (yield self.application.twsessionmgr.find_player(self, name, password))
    except MessageException as ex:
        formerror = str(ex)
        self.render('main.html', formerror=formerror, init_name=name)
        return
    if (not res):
        formerror = 'The name and password do not match.'
        email.render('main.html', formerror=formerror, init_name=name)
        return
    fieldname = name
    uid = res['_id']
    email = res['email']
    name = res['name']
    if (locked and (not res.get('admin', None))):
        formerror = 'Sign-ins are not allowed at this time.'
        self.render('main.html', formerror=formerror, init_name=name)
        return
    self.set_cookie('tworld_name', tornado.escape.url_escape(fieldname), expires_days=30)
    res = (yield self.application.twsessionmgr.create_session(self, uid, email, name))
    self.application.twlog.info('Player signed in: %s (session %s)', email, res)
    self.redirect('/play')

dataset/ETHPy150Open erkyrath/tworld/lib/tweblib/handlers.py MainHandler.post/VarMisuse@342/497 `self`->`email`