def send_email(self): if (self.email_type == VENDOR_EMAIL_CONFIRM or self.email_type == USER_EMAIL_CONFIRM) \ and not self.email_confirmed: token = md5_with_time_salt(self.role.data, self.id.data) redis_set(CONFIRM_EMAIL, token, {'role': self.role.data, 'id': self.id.data, 'email': self.email.data, 'action': 'confirm'}, serialize=True) url = url_for('service.verify', token=token, _external=True) send_email(self.email.data, EMAIL_CONFIRM_SUBJECT, self.email_type, url=url)
def send_email(self): if self.email_type == USER_RESET_PASSWORD: token = md5_with_time_salt(self.email.data) redis_set(CONFIRM_EMAIL, token, { 'email': self.email.data, 'action': 'reset_password' }, serialize=True) url = url_for('service.verify', token=token, _external=True) send_email(self.email.data, EMAIL_CONFIRM_SUBJECT, self.email_type, url=url)
def send_email(self): if (self.email_type == VENDOR_EMAIL_CONFIRM or self.email_type == USER_EMAIL_CONFIRM) \ and not self.email_confirmed: token = md5_with_time_salt(self.role.data, self.id.data) redis_set(CONFIRM_EMAIL, token, { 'role': self.role.data, 'id': self.id.data, 'email': self.email.data, 'action': 'confirm' }, serialize=True) url = url_for('service.verify', token=token, _external=True) send_email(self.email.data, EMAIL_CONFIRM_SUBJECT, self.email_type, url=url)
def update(self): if self.type == USER_USERNAME_SETTING: if self.username.data != current_user.username and current_user.username_revisable: current_user.username = self.username.data current_user.username_revisable = False elif self.type == USER_PASSWORD_SETTING: current_user.password = self.password.data db.session.commit() logout_user() identity_changed.send(current_app._get_current_object(), identity=AnonymousIdentity()) return else: # email current_user.email = self.email.data current_user.email_confirmed = False token = md5_with_time_salt(self.email.data) redis_set(CONFIRM_EMAIL, token, {'email': self.email.data, 'role': 'user', 'action': 'confirm', 'id': current_user.id}, serialize=True) url = url_for('service.verify', token=token, _external=True) send_email(self.email.data, EMAIL_CONFIRM_SUBJECT, USER_EMAIL_CONFIRM, url=url) db.session.commit()
def send_email(self): if self.email_type == USER_RESET_PASSWORD: token = md5_with_time_salt(self.email.data) redis_set(CONFIRM_EMAIL, token, {'email': self.email.data, 'action': 'reset_password'}, serialize=True) url = url_for('service.verify', token=token, _external=True) send_email(self.email.data, EMAIL_CONFIRM_SUBJECT, self.email_type, url=url)
def invite_distributor(): if request.method == 'POST': token = md5_with_time_salt(current_user.id) redis_set(DISTRIBUTOR_REGISTER, token, current_user.id) return url_for('distributor.verify', token=token, _external=True) return render_template('vendor/invitation.html', vendor=current_user)