def POST(self): name = self.env["members"]["username"] password = self.env["members"]["password"] passwordTwice = self.env["members"]["passwordTwice"] level = self.env["members"]["level"] or "" email = self.env["members"]["email"] or "" emailVis = True \ if self.env["members"].has_key("emailVis") else False disable = True \ if self.env["members"].has_key("disable") else False if password == passwordTwice \ and password != "": try: newUser = userORM(name, password) newUser.level = level newUser.email = email newUser.emailVisibility = emailVis newUser.disable = disable newUser.save() self.session.pushAlert("New user with username `%s` \ created" % name, "Yay", "success") self.head = ("303 SEE OTHER", [("location", str("/admin/users/edit/%s"%newUser.id))]) except: view = adminNewUserTmpl(searchList=[self.tmplSearchList]) view.usernameError = True self.session.pushAlert("You're going to have to pick a new \ username, `%s` is taken." % name, "", "error") return view else: view = adminNewUserTmpl(searchList=[self.tmplSearchList]) view.passwordError = True self.session.pushAlert("Those passwords don't match, please \ try again.", "", "error") return view
def initialSetup(): print "Setting up inital users, flags and templates..." if config.initial.has_key("users"): for user in config.initial["users"]: newUser = um.userORM(user["username"], user["password"]) print "\tAdding new user `%s`"%user["username"] print "\t\tpassword `%s`"%user["password"] if user.has_key("level"): print "\t\tlevel `%d`"%user["level"] newUser.level = user["level"] else: print "\t\tlevel `100` - god" newUser.level = 100 newUser.save() if config.initial.has_key("flags"): pass if config.initial.has_ley("templates"): pass
def POST(self): """ """ if self.env["cfg"].enableRegistration: givenEmail = self.env["members"]["email"] if self.env["members"].has_key("email") else "" username = self.env["members"]["username"] if self.env["members"].has_key("username") else "" passwordOnce = self.env["members"]["passwordOnce"] if self.env["members"].has_key("passwordOnce") else "" passwordTwice = self.env["members"]["passwordTwice"] if self.env["members"].has_key("passwordTwice") else "" foundEmail = um.findByEmail(givenEmail) foundName = um.findByUsername(username) if passwordOnce == passwordTwice and passwordOnce != "" and not (foundEmail or foundName): """ Passwords match, password isn't null and no one Else has the same username or email. If this is all true then We can go ahead and make a new user and while we're at it lets log them in also. """ newUser = um.userORM(username, passwordOnce) newUser.loginThis(self.env["cookie"]) newUser.save() self.session.pushAlert( "You can now log in with the \ information you gave us!", "Congrats!", "success", ) self.head = ("303 SEE OTHER", [("location", "/your/flags")]) else: """ If none, or one of those isn't true then we have a problem... """ view = authRegisterTmpl(searchList=[self.tmplSearchList]) view.email = givenEmail view.username = username if foundName: """ Someone with the same username, thats not allowed... """ self.session.pushAlert( "There is already a person in our \ system with that username, please choose another", "Oh no!", "error", ) view.usernameError = True elif foundEmail: """ Already someone with that email in the system... """ self.session.pushAlert( "There is already someone with that \ email in our system, are you sure you don't already\ have an account, or have already requested an invite?", "Oh no!", "error", ) view.emailError = True elif passwordOnce != "" and passwordOnce != passwordTwice: """ Password isn't null but doesn't match """ view.passwordMatchError = True return view else: self._404()
def POST(self): """ """ if self.env["cfg"].enableRequests: token = self.env["members"][0] givenEmail = self.env["members"]["email"] \ if self.env["members"].has_key("email") else "" username = self.env["members"]["username"] \ if self.env["members"].has_key("username") else "" passwordOnce = self.env["members"]["passwordOnce"] \ if self.env["members"].has_key("passwordOnce") else "" passwordTwice = self.env["members"]["passwordTwice"] \ if self.env["members"].has_key("passwordTwice") else "" email = su.requestDetoken(token) foundEmail = um.findByEmail(email) foundName = um.findByUsername(username) if email == givenEmail \ and passwordOnce == passwordTwice \ and passwordOnce != "" \ and not (foundEmail or foundName): #Passwords match, emails match, password isn't null and no one #Else has the same username or email. If this is all true then #We can go ahead and make a new user and while we're at it #lets log them in also. When this happends we delete the request #also so its not just sitting around in our system newUser = um.userORM(username, passwordOnce) newUser.loginThis(self.env["cookie"]) newUser.save() req = rm.requestORM.find(email) req.delete() self.session.pushAlert("You can now log in with the \ information you gave us!", "Congrats!", "success") self.head = ("303 SEE OTHER", [("location", "/you/flags")]) else: #If none, or one of those isn't true then we have a problem... view = requestsRegisterTmpl(searchList=[self.tmplSearchList]) view.email = givenEmail view.token = token view.username = username if foundName: #Someone with the same username, thats not allowed... self.session.pushAlert("There is already a person in our \ system with that username, please choose another", "Oh no!", "error") view.usernameError = True elif foundEmail: #Already someone with that email in the system... self.session.pushAlert("There is already someone with that \ email in our system, are you sure you don't already\ have an account, or have already requested an invite?", "Oh no!", "error") view.emailError = True elif passwordOnce != "" and passwordOnce != passwordTwice: #Password isn't null but doesn't match view.passwordMatchError = True elif email != givenEmail: #And finally, if the email they give doesn't match the invites #email... view.emailMatchError = True return view else: self._404()