def send_pm(name): user = User.objects(name=name).first() if user is None: abort(404) form = ComposePMForm(request.form) if request.method == 'POST': if not form.validate(): return render_template('profile_send_pm.html', user=user, form=form) notification = PMNotification( receiver=UserTarget(user=user), sender=UserTarget(user=current_user._get_current_object()), source="Website", message=form.text.data) # receiver=user.to_dbref(), sender_type=1, sender_user=current_user.to_dbref(), # preview="PM from %s" % current_user.name, deletable=True, type="pm", module="pm", render_type=1, # data={'text': form.text.data}) notification.save() flash('The PM has been successfully sent.', category='success') return redirect(user.get_profile_url()) return render_template('profile_send_pm.html', user=user, form=form, title="Send PM - " + user.name + " - Profile")
def verify_email(data): payload = serializer.loads(data, salt="MailVerification") if len(payload) != 4 or payload[0] != DATA_VER: abort(404) if (datetime.utcnow() - datetime.fromtimestamp(payload[3])).seconds > 3600: abort(404) user = User.objects(name=payload[1]).first() if user is None: abort(404) if user.mail_verified: abort(404) if user.mail != payload[2]: abort(404) user.mail_verified = True user.save() return 'Success'
def verify_email(data): payload = serializer.loads(data, salt="MailVerification") if len(payload) != 4 or payload[0] != DATA_VER: abort(404) if (datetime.utcnow() - datetime.fromtimestamp(payload[3])).seconds > 3600: abort(404) user = User.objects(name=payload[1]).first() if user is None: abort(404) if user.mail_verified: abort(404) if user.mail != payload[2]: abort(404) user.mail_verified = True user.save() return "Success"
def send_pm(name): user = User.objects(name=name).first() if user is None: abort(404) form = ComposePMForm(request.form) if request.method == 'POST': if not form.validate(): return render_template('profile_send_pm.html', user=user, form=form) notification = PMNotification(receiver=UserTarget(user=user), sender=UserTarget(user=current_user._get_current_object()), source="Website", message=form.text.data) # receiver=user.to_dbref(), sender_type=1, sender_user=current_user.to_dbref(), # preview="PM from %s" % current_user.name, deletable=True, type="pm", module="pm", render_type=1, # data={'text': form.text.data}) notification.save() flash('The PM has been successfully sent.', category='success') return redirect(user.get_profile_url()) return render_template('profile_send_pm.html', user=user, form=form, title="Send PM - " + user.name + " - Profile")