def logout(cls): sid = session.pop('id', None) if not sid: return False key = cls.KEY_PREFIX.format(sid) redis.delete(key) return True
def signup(token): email, key = get_email_from_signature(token, 'signup') social_service = session.get('social.service') social_uuid = session.get('social.uuid') if social_service and social_uuid: social = SocialUser.query.get((social_service, social_uuid)) if social.user_id: social = None else: social = None form = RegisterForm() form.email.data = email if form.validate_on_submit(): user = form.create_user() redis.delete(key) if social: session.pop('social.service', None) session.pop('social.uuid', None) social.user_id = user.id with db.auto_commit(): db.session.add(social) UserSession.login(user, True) return redirect('/') return render_template( 'account/signup.html', form=form, email=email, social=social, )
def change_email(token): email, key = get_email_from_signature(token, 'email') user = User.query.filter_by(email=email).first_or_404() form = EmailForm() if form.validate_on_submit(): user.email = form.email.data with db.auto_commit(): db.session.add(user) redis.delete(key) return redirect('/') return render_template( 'account/email.html', form=form, user=user, )
def flush(self): redis.delete(self.key)