def login(self):
        '''
        user login.
        '''
        post_data = self.get_post_data()

        if 'next' in post_data:
            next_url = post_data['next']
        else:
            next_url = '/'

        u_name = post_data['user_name']
        u_pass = post_data['user_pass']

        result = MUser.check_user_by_name(u_name, u_pass)

        # Todo: the kwd should remove from the codes.
        if result == 1:
            self.set_secure_cookie("user", u_name)
            MUser.update_time_login(u_name)
            self.redirect(next_url)
        elif result == 0:
            self.set_status(401)

            self.render('user/user_relogin.html',
                        cfg=config.CMS_CFG,
                        kwd={
                            'info': '密码验证出错，请重新登陆。',
                            'link': '/user/login',
                        },
                        userinfo=self.userinfo)
        elif result == -1:
            self.set_status(401)
            self.render('misc/html/404.html',
                        cfg=config.CMS_CFG,
                        kwd={
                            'info': '没有这个用户',
                            'link': '/user/login',
                        },
                        userinfo=self.userinfo)
        else:
            self.set_status(305)
            self.redirect("{0}".format(next_url))