diff --git a/Files/Chrys/AES.txt b/Files/Chrys/AES.txt deleted file mode 100644 index 583cb37..0000000 --- a/Files/Chrys/AES.txt +++ /dev/null @@ -1,15 +0,0 @@ -https://youtu.be/O4xNJsjtN6E - -https://youtu.be/6KfJXl-Kvws - -dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq9zNUsIT7yvz43duMKygPZw== (64) -dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq -9zNUsIT7yvz43duMKygPZw== (F7 33 54 B0 84 FB CA FC F8 DD DB 8C 2B 28 0F 67) - -1~15 : 24 -16~31 : 44 -/!\ --->{32~47 : 64}<--- /!\ - -01110101 01011101 01001100 11101101 10011110 01100010 10011110 11011101 10111110 01000010 00000100 01101101 00001110 10110100 00001001 01000101 11100111 01001000 10010011 11101110 10100101 10100111 01110011 10111100 00011010 10000101 01000001 00111011 00111011 11101010 11110111 00110011 01010100 10110000 10000100 11111011 11001010 11111100 11111000 11011101 11011011 10001100 00101011 00101000 00001111 01100111 - -dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq9zNUsIT7yvz43duMKygPZw== diff --git a/Files/SuperUser/AES.txt b/Files/SuperUser/AES.txt deleted file mode 100644 index 583cb37..0000000 --- a/Files/SuperUser/AES.txt +++ /dev/null @@ -1,15 +0,0 @@ -https://youtu.be/O4xNJsjtN6E - -https://youtu.be/6KfJXl-Kvws - -dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq9zNUsIT7yvz43duMKygPZw== (64) -dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq -9zNUsIT7yvz43duMKygPZw== (F7 33 54 B0 84 FB CA FC F8 DD DB 8C 2B 28 0F 67) - -1~15 : 24 -16~31 : 44 -/!\ --->{32~47 : 64}<--- /!\ - -01110101 01011101 01001100 11101101 10011110 01100010 10011110 11011101 10111110 01000010 00000100 01101101 00001110 10110100 00001001 01000101 11100111 01001000 10010011 11101110 10100101 10100111 01110011 10111100 00011010 10000101 01000001 00111011 00111011 11101010 11110111 00110011 01010100 10110000 10000100 11111011 11001010 11111100 11111000 11011101 11011011 10001100 00101011 00101000 00001111 01100111 - -dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq9zNUsIT7yvz43duMKygPZw== diff --git a/app.db b/app.db deleted file mode 100644 index d8ad5fd..0000000 Binary files a/app.db and /dev/null differ diff --git a/app/__init__.py b/app/__init__.py index 1076add..66d5e8a 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -3,12 +3,14 @@ from config import Config from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import LoginManager +from flask_wtf.csrf import CSRFProtect app = Flask(__name__) app.config.from_object(Config) db = SQLAlchemy(app) migrate = Migrate(app, db) login = LoginManager(app) +csrf = CSRFProtect(app) # There is the dictionnary, which can be usefull when you want to change the language. words = { @@ -16,6 +18,7 @@ words = { 'nameHome' : 'Home', 'nameUpload' : 'Upload', 'nameLogin' : 'Login', + 'nameView' : 'View', 'nameRegister' : 'Register', 'termLogout' : 'Logout', 'termChoose' : 'Choose a directory', @@ -27,7 +30,8 @@ words = { 'termIsAdmin' : 'Is Admin?', 'termRegistered' : 'Registered: ', 'ErrorInvalid' : 'Invalid Password or Username', - 'ErrorUsername' : 'Username already used' + 'ErrorUsername' : 'Username already used', + 'ErrorNoFiles' : 'There is no files which belong to this user' } from app import routes, models \ No newline at end of file diff --git a/app/__pycache__/__init__.cpython-38.pyc b/app/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 94ad52a..0000000 Binary files a/app/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/app/__pycache__/forms.cpython-38.pyc b/app/__pycache__/forms.cpython-38.pyc deleted file mode 100644 index 46818af..0000000 Binary files a/app/__pycache__/forms.cpython-38.pyc and /dev/null differ diff --git a/app/__pycache__/models.cpython-38.pyc b/app/__pycache__/models.cpython-38.pyc deleted file mode 100644 index ed2d761..0000000 Binary files a/app/__pycache__/models.cpython-38.pyc and /dev/null differ diff --git a/app/__pycache__/routes.cpython-38.pyc b/app/__pycache__/routes.cpython-38.pyc deleted file mode 100644 index c913f58..0000000 Binary files a/app/__pycache__/routes.cpython-38.pyc and /dev/null differ diff --git a/app/routes.py b/app/routes.py index 63946c3..5d3301a 100644 --- a/app/routes.py +++ b/app/routes.py @@ -13,7 +13,7 @@ from app.models import User, File # Parameters: # 'page.html' # dico=words (Usefull to translate all the site with one dictionary) -# userloged=current_user (Usefull to know if the user is logged in, and if yes, his name) +# userlogged=current_user (Usefull to know if the user is logged in, and if yes, his name) # title='title' (Optional: If you want to change the title of the page, You can also use words['pageTitle'] to change faster when you want to translate) # Home page @@ -21,7 +21,7 @@ from app.models import User, File @app.route('/') @app.route('/home') def home(): - return render_template('home.html', title=words['nameHome'], dico=words, userloged=current_user) + return render_template('home.html', title=words['nameHome'], dico=words, userlogged=current_user) # Login page # Use it to login @@ -38,7 +38,7 @@ def login(): return redirect(url_for('login')) login_user(user, remember=form.remember_me.data) return redirect(url_for('home')) - return render_template('login.html', title=words['nameLogin'], dico=words, form=form, userloged=current_user) + return render_template('login.html', title=words['nameLogin'], dico=words, form=form, userlogged=current_user) # Logout page # Use it to logout @@ -66,7 +66,7 @@ def register(): os.mkdir(os.path.join(app.config['FILES_DIR'], form.username.data)) flash(words['termRegistered'] + form.username.data) return redirect(url_for('home')) - return render_template('register.html', title=words['nameRegister'], dico=words, form=form, userloged=current_user) + return render_template('register.html', title=words['nameRegister'], dico=words, form=form, userlogged=current_user) # Upload page # Use it to upload a file @@ -86,9 +86,9 @@ def upload(): db.session.add(filetodb) db.session.commit() return redirect(url_for('home')) - return render_template('upload.html', title=words['nameUpload'], dico=words, form=form, userloged=current_user) + return render_template('upload.html', title=words['nameUpload'], dico=words, form=form, userlogged=current_user) -# Users' download pages +# Download pages # Use it to download a file # Redirect automatically to the home page if the user isn't logged in # If the id is'nt reconized, redirect automatically to the home page @@ -103,4 +103,36 @@ def download(id): if filetodb.user == current_user or current_user.isAdmin == True: return send_from_directory(os.path.join(app.config['FILES_DIR'], filetodb.user.username), filetodb.name, as_attachment=True) else: - return redirect(url_for('home')) \ No newline at end of file + return redirect(url_for('home')) + +# Users' View Page +# It will show all files which belong to the requested user +# Redirect automatically to the home page if the user isn't logged in or is an Admin +@app.route('/view') +def viewUser(): + if not current_user.is_authenticated: + return redirect(url_for('home')) + if current_user.isAdmin: + return redirect(url_for('home')) + +# Admins' View Page +# It will show all files which belong to the requested user +# Redirect automatically to the home page if the user isn't logged in or isn't an Admin +# If the id is'nt reconized, redirect automatically to the home page +@app.route('/view/') +def viewAdmin(id): + if not current_user.is_authenticated: + return redirect(url_for('home')) + if not current_user.isAdmin: + return redirect(url_for('home')) + user = User.query.filter_by(id=id).first() + if not user: + return redirect(url_for('home')) + files = [] + for filefromdb in File.query.all(): + if filefromdb.user == user: + files.append(filefromdb) + if not len(files): + flash(words['ErrorNoFiles']) + return redirect(url_for('home')) + return render_template('view.html', title=words['nameView'] + ' - ' + user.username, dico=words, userlogged=current_user, files=files) \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html index 557fc36..c43c823 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -10,16 +10,16 @@
{{ dico['nameApp'] }} {{ dico['nameHome'] }} - {% if userloged.is_authenticated == False %} + {% if userlogged.is_authenticated == False %} {{ dico['nameLogin'] }} {% else %} {{ dico['nameUpload'] }} - {% if userloged.isAdmin == True %} + {% if userlogged.isAdmin == True %} {{ dico['nameRegister'] }} {% endif %} {{ dico['termLogout'] }} {% endif %} - {{ userloged.username }} + {{ userlogged.username }}
{% with messages = get_flashed_messages() %} {% if messages %} diff --git a/app/templates/view.html b/app/templates/view.html new file mode 100644 index 0000000..2ba1279 --- /dev/null +++ b/app/templates/view.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block content %} +{% for file in files %} +
+ | {{ file.name }}, {{ file.user.username }} | +
+{% endfor %} +{% endblock %} \ No newline at end of file