在这里,我想使用电子邮件验证进行用户注册,这是我的代码:
@app.route('/register', methods=['GET','POST'])
def createuser():
json = request.form
username = json['username']
password = json['password']
email = json['email']
token = s.dumps(email, salt='email-confirm')
msg = Message("EMAIL CONFIRMATION",
sender='EMAIL_VERIFICATION',
recipients=[email])
msg.body = "Yo! Thank you for registering in our website please use this code\n The code will expired in 15 minutes\n"+token
mail.send(msg)
return jsonify({'message':'please verification email !'})
@app.route('/register/<token>',methods=['GET','POST'])
def confirm(token):
try:
email = s.loads(token, salt='email-confirm', max_age= 900)
mongo.db.login.insert({'username': username, 'password': password, 'email': email})
return jsonify({'message': 'User registered'})
except:
return jsonify({'message': 'Wrong Token'})
在应用程序路由“ / register / token”中如何通过api createuser()传递用户名,密码,电子邮件,以便我可以在确认中插入
谢谢;)