

def post(self):
    username = self.get_argument('username', None)
    password = self.get_argument('password', None)
    if ((not username) or (not password)):
        self.flash.error = 'You must enter a username and password to proceed. Please try again.'
        self.redirect('/login')
        return
    pw = hashlib.sha1(password).hexdigest()
    username = User.normalize(username)
    user = User.lookup(username)
    if ((not user) or (user['password'] != pw)):
        self.flash.error = 'Login not valid'
        self.redirect('/login')
        return
    if user.is_suspended():
        self.flash.error = 'Sorry the account you specified has been suspended.'
        self.redirect('/')
        return
    user.history.last_login = datetime.datetime.utcnow()
    Mongo.db.ui.users.update({
        '_id': username,
    }, {
        '$set': {
            'history.last_login': user.history.last_login,
        },
        '$inc': {
            'history.num_logins': 1,
        },
    })
    self.session['username'] = user._id
    if (self.get_argument('keep_logged_in', False) == 'on'):
        self.session['keep_logged_in'] = True
    self.set_current_user(user)
    self.flash.notice = ('Welcome, %s' % user._id)
    forwardUrl = self.get_argument('next', '/')
    self.redirect(forwardUrl)

dataset/ETHPy150Open trendrr/whirlwind/whirlwind/conf/app_template/application/controllers/account_controller.py LoginHandler.post/original