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)
评论列表
文章目录