def post(self):
        username = self.get_argument("username",None)
        password = self.get_argument("password",None)
        
        if not username or not password:
            # do something
            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)
        
        #check the password.
        if not user or user['password'] != pw:
            # do something
            self.flash.error = "Login not valid"
            self.redirect("/login")
            return
        
        # check if user is suspended.
        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}
                                                    })        
        #add to the session.
        self.session['username'] = user._id
        #check keep_logged_in
        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