def _set_user_oauth_state(provider_name): if current_user.is_authenticated: state = shortuuid.uuid() redis_cli.setex(__key_user_oauth_state(provider_name, current_user), timedelta(minutes=1), state) return state return ''
def _send_reset_password_email(email): key = __key_reset_password_code(email) reset_password_code = shortuuid.uuid() redis_cli.setex(key, timedelta(hours=1), reset_password_code) reset_password_url = url_for('user.reset_password_page', e=base64.urlsafe_b64encode(email), c=reset_password_code, _external=True) send_email(email, u'重置密码', 'reset_password.html', reset_password_url=reset_password_url)
def _send_activate_email(email): key = __key_activate_email_code(email) activate_code = shortuuid.uuid() redis_cli.setex(key, timedelta(days=1), activate_code) activate_url = url_for('user.activate_email', e=base64.urlsafe_b64encode(email), c=activate_code, _external=True) send_email(email, u'邮箱激活', 'activate_email.html', activate_url=activate_url)
def _generate_captcha(email): b64_img, code = generate_captcha() redis_cli.setex(__key_captcha(code), current_app.config['LOGIN_CAPTCHA_EXPIRES_TIMEDELTA'], email) return b64_img