From baf06d310604bd473a97bf345c0de2ce3da39e71 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Thu, 14 Nov 2019 10:01:45 +0100
Subject: [PATCH] Add user directory on registration
---
app/auth/views.py | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/app/auth/views.py b/app/auth/views.py
index 0b124a82..146294f3 100644
--- a/app/auth/views.py
+++ b/app/auth/views.py
@@ -1,11 +1,13 @@
from app import db
from app.email import send_email
from app.models import User
-from flask import flash, redirect, render_template, request, url_for
+from flask import (current_app, flash, redirect, render_template, request,
+ url_for)
from flask_login import current_user, login_required, login_user, logout_user
from . import auth
from .forms import (LoginForm, PasswordResetForm, PasswordResetRequestForm,
RegistrationForm)
+import os
@auth.route('/login', methods=['GET', 'POST'])
@@ -46,14 +48,22 @@ def register():
username=form.username.data)
db.session.add(user)
db.session.commit()
- token = user.generate_confirmation_token()
- send_email(user.email,
- 'Confirm Your Account',
- 'auth/email/confirm',
- token=token,
- user=user)
- flash('A confirmation email has been sent to you by email.')
- return redirect(url_for('auth.login'))
+ dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
+ str(job.user_id), 'jobs', str(job.id))
+ try:
+ os.makedirs(dir)
+ except OSError:
+ flash('[ERROR]!')
+ user.delete()
+ else:
+ token = user.generate_confirmation_token()
+ send_email(user.email,
+ 'Confirm Your Account',
+ 'auth/email/confirm',
+ token=token,
+ user=user)
+ flash('A confirmation email has been sent to you by email.')
+ return redirect(url_for('auth.login'))
return render_template('auth/register.html.j2',
form=form,
title='Register')