welcome.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Tktr 作者: Intuity 项目源码 文件源码
def welcome_view_do(self):
        if not self.has_queued:
            return HTTPFound(location=self.request.route_path("queue"))
        # Get username and password
        username = self.request.POST["username"].lower()
        password = self.request.POST["password"]
        # Check if user exists and is non-raven
        if not username in self.request.root.users:
            self.request.session.flash("Your username or password was incorrect", "error")
            return HTTPFound(location=self.request.route_path("welcome"))
        user = self.request.root.users[username]
        if user.profile != None and user.profile.raven_user:
            self.request.session.flash("Your account appears to be a Raven account, please use the Raven login instead.", "error");
            return HTTPFound(location=self.request.route_path("welcome"))
        # Check password
        if user.password != salt_password(password, user.password_salt):
            self.request.session.flash("Your username or password was incorrect", "error")
            return HTTPFound(location=self.request.route_path("welcome"))
        # Ok, this all looks ok - lets go!
        header = remember(self.request, user.__name__)
        self.request.session["user_id"] = user.__name__
        if user.profile == None:
            profile = UserProfile()
            profile.raven_user = False
            profile.__parent__ = user
            profile.__name__ = user.__name__ + "-profile"
            user.profile = profile
            return HTTPFound(location=self.request.route_path('user_profile_edit'), headers=header)
        elif None in [user.profile.dob, user.profile.fullname]:
            return HTTPFound(location=self.request.route_path('user_profile_edit'), headers=header)
        else:
            return HTTPFound(location=self.request.route_path('user_profile'), headers=header)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号