def create_key(self, owner, app_name, email, url): """ Creates an API key and stores it in the global DB. @param owner: Name of the person/entity requesting the key. @type owner: String @param app_name: Name of the application that will be using the API key. @type app_name: String @param email: Contact address of the entity requesting the key. @type email: String @param url: Web address of the person/entity requesting the key. @type url: String @return: New API key @rtype: String """ try: validation.required(owner, 'owner') validation.required(app_name, 'app_name') validation.email(email) except errors.ValidationError, ex: self.log.warning("Validation failure: %s" % str(ex)) raise errors.APIError, str(ex)
def generate_invite(self, owner_userid, recipients, sender_name, subj, msg, sender_email): """ Generates an invite request to a particular user. @param owner_username: User making the invite @type owner_username: String @param recipients: List of Zoto usernames @type recipients: List/tuple @param sender_name: Plaintext name of the sender (for personal greeting in the email) @type sender_name: String @param subj: Subject of the email @type subj: String @param msg: Body of the message (to be inserted into Zoto canned text) @type msg: String @param sender_email: Email address of the sender @type sender_email: String """ try: owner_userid = validation.cast_integer(owner_userid, 'owner_userid') rec = [] for email_addr in recipients: rec.append(validation.email(email_addr)) recipients = rec sender_name = validation.string(sender_name) subj = validation.string(subj) msg = validation.string(msg) sender_email = validation.email(sender_email) except errors.ValidationError, ex: return utils.return_deferred_error(ex.value)
def post(self): user_username = self.request.get('username') user_password = self.request.get('password') user_verify = self.request.get('verify') user_email = self.request.get('email') venmo_email = self.request.get('venmo_email') bio = self.request.get('bio') username = validation.username(user_username) password = validation.password(user_password) verify = validation.verify(user_verify, user_password) email = validation.edu_email(user_email) venmo_email_verify = validation.email(venmo_email) userError="" passError="" verifyError="" emailError="" venmoEmailError = "" if not username: userError = "That's not a valid username." user_username="" if not password: passError = "That wasn't a valid password." if not verify: verifyError = "Your passwords didn't match." if not email: emailError = "That's not a valid email." user_email="" if venmo_email != "" and venmo_email_verify is None: venmoEmailError = "That's not a valid email. Leave empty if you don't have one" venmo_email="" if username and password and verify and email and (venmoEmailError == ""): passHash = validation.make_pw_hash(username, password) code = validation.make_salt() user = User(username = username, passHash=passHash, email=email, bio=bio, venmo_email=venmo_email, activationCode=code) u = User.all().filter('username ='******'Content-Type'] = 'text/plain' cookie_val = validation.make_secure_val(str(user_id)) self.response.headers.add_header('Set-Cookie',str('user=%s; Path=/' % cookie_val)) self.sendActivationEmail(email, code) self.redirect("/home") else: self.write_form(userError, passError, verifyError, emailError, venmoEmailError, user_username, user_email, bio=bio)
def post(self): user = User.get_by_id(self.getUser()) if "updatePassword" in self.request.POST: password_success, password_error = "", "" if validation.valid_pw(user.username, self.request.get('currentPassword'), user.passHash): new_pass = self.request.get('new_password') if new_pass == self.request.get('verifyNewPassword'): user.passHash = validation.make_pw_hash( user.username, new_pass) user.put() password_success = "Password Changed Successfully!" else: password_error = "New passwords are not the same" else: password_error = "That is not your current password" self.render('admin.html', user=user, update_error=password_error, update_success=password_success) elif "otherChanges" in self.request.POST: user_email = self.request.get('email') venmo_email = self.request.get('venmo_email') email = validation.edu_email(user_email) venmo_email_verify = validation.email(venmo_email) email_error, venmo_email_error, update_success, update_error = "", "", "", "" if not email: email_error = "That's not a valid email." user_email = "" if venmo_email != "" and venmo_email_verify is None: venmo_email_error = "Invalid email. This is an optional field." venmo_email = "" if email and (venmo_email_error == ""): try: user.email = user_email user.venmo_email = venmo_email user.bio = self.request.get('bio') user.put() update_success = "Succesfully Updated!" except: update_error = "Could not save changes :(" self.render('admin.html', user=user, update_success=update_success, update_error=update_error, email_error=email_error, venmo_email_error=venmo_email_error)
def add_contact_via_email(self, owner_userid, email): """ Add a contact to the user's account. @param owner_username: Owner of the account @type owner_username: String @param contact_username: User being added as a contact @type owner_username: String """ try: owner_userid = validation.cast_integer(owner_userid, 'owner_userid') email = validation.email(email) except errors.ValidationError, ex: return utils.return_deferred_error(ex.value)