Compare commits

..

No commits in common. "90946549565a57191853a9b243c5f92d726aa685" and "083a7147ffd87909efe26a3ed7c76c88f122c68c" have entirely different histories.

11 changed files with 40 additions and 51 deletions

View File

@ -1,13 +1,8 @@
# L'adresse de base de votre site.
# example BASE_URL="http://localhost/"
BASE_URL="https://example.con/"
# Essentiels pour les cookies
SECRET_KEY="CHANGE ME"
SECRET_KEY="fksmlfkljklknfzqlknfzqlkezq"
# Dossier où seront stocker les fichiers
DOSSIER_APP = "./users/"
DOSSIER_APP = "users/"
# Fichiers sqlite
DATABASE = "./base.db"

View File

@ -80,7 +80,6 @@ def create_app():
app.register_blueprint(profil)
app.register_blueprint(logs)
app.register_blueprint(loginlogout)
app.register_blueprint(mygallery)
return app

View File

@ -36,6 +36,8 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-comment" aria-hidden="true"></span> Ma Messagerie </a>
<ul class="dropdown-menu" role="menu">
<li><a href="/mymailbox/"> <span class="glyphicon glyphicon-lock" aria-hidden="true"></span>
Changer mon mot de passe </a></li>
<li><a href="/mymailbox/alias"><span class="glyphicon glyphicon-sunglasses" aria-hidden="true"></span>
Gerer mes alias</a></li>
@ -48,11 +50,11 @@
</a>
</li>
<li {% if section == "Profil" %} class="dropdown active" {% else %} class="dropdown" {% endif %}>
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> <span id="majuscule">{{ session['username'] }} </span><span class="caret"></span></a>
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> <span id="majuscule">{{ session['username'] }} </span><span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="/profil/"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Profil</a></li>
<li><a href="/profil/change-password/"> <span class="glyphicon glyphicon-lock" aria-hidden="true"></span>
Changer mon mot de passe </a></li>
<li><a href="/parametres/"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> Paramètres</a></li>
<li class="divider"></li>
<li><a href="/invitation/"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> Inviter une personne</a></li>
<!--<li class="dropdown-header">Nav header</li>-->
</ul>

View File

@ -27,7 +27,7 @@
<br>
{% if signin_enable %}
<form method="POST" action="{{ url_inscription }}">
<form method="POST" action="{{ base_url }}">
<input type="text" name="user" id="user" placeholder="Pseudo" class="form-control"><br />
<div class="col-sm-7">
<input type="text" name="mail" id="mail" placeholder="Adresse mail" class="form-control" size="2"> <br/>

View File

@ -21,8 +21,8 @@
{% if token %}
<h3> Votre lien d'inscription en cours: </h3>
<a href="{{ url_invitation }}">
{{ url_invitation }}
<a href="{{ base_url }}/{{ token }}">
{{base_url }}/{{ token }}
</a>
{% else %}
<h3> Pas d'invitation en attente </h3>

View File

@ -18,8 +18,6 @@ DOSSIER_PERSO= app.config['DOSSIER_APP']
extensionimg = app.config['EXT_IMG']
DATABASE = app.config['DATABASE']
BASE_URL = app.config['BASE_URL']
##################################################################################################
@ -57,7 +55,7 @@ def racine_blog():
conn.close()
return render_template('blog.html', section='Post-it', posts=posts)
else:
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)
@ -71,7 +69,7 @@ def delete(post):
conn.close()
return redirect(url_for('post-it.racine_blog'))
else:
return redirect(BASE_URL, code=401) # sinon on redirige vers login
return redirect(url_for('loginlogout.login', _external=True), code=401) # sinon on redirige vers login
@postit.route('/edit/<post>', methods=['GET', 'POST'])
def edit(post):
@ -98,7 +96,7 @@ def edit(post):
oldpost=oldpost)
else:
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401) # sinon on redirige vers login)
@postit.route('/postit/board', methods=['GET'])
def viewsheet():
@ -112,4 +110,4 @@ def viewsheet():
conn.close()
return render_template('board.html', section='Post-it', posts=posts)
else:
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)

View File

@ -21,8 +21,6 @@ DOSSIER_PERSO= app.config['DOSSIER_APP']
extensionimg = app.config['EXT_IMG']
DATABASE = app.config['DATABASE']
BASE_URL= app.config['BASE_URL']
##################################################################################################
@filesupload.route( '/filesupload/', methods=['GET', 'POST'])
@ -83,7 +81,7 @@ def uploadfiles():
resp.set_cookie('username', session['username'])
return resp
else :
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)
@filesupload.route('/view/')
@ -105,9 +103,9 @@ def list():
listeFichiers=listeFichiers)
else :
flash(u'Aucun fichier uploadé ! Redirection vers Upload', 'error')
return redirect(url_for('filesupload.uploadfiles'))
return redirect(url_for('filesupload.uploadfiles', external=True))
else :
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)
@filesupload.route('/myfiles/<filename>')
def myfiles(filename):
@ -116,7 +114,7 @@ def myfiles(filename):
return send_from_directory(
os.path.join(DOSSIER_PERSO, UTILISATEUR, 'files'), filename )
else :
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login'), code=401)
@filesupload.route('/remove/<nom>')
def remove(nom):
@ -136,4 +134,4 @@ def remove(nom):
return redirect(url_for('filesupload.list', _external=True)) # sinon on redirige vers la liste, avec un message d'erreur
else :
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login'), code=401)

View File

@ -43,7 +43,7 @@ def myimg(filename):
return send_from_directory(
os.path.join(DOSSIER_PERSO, UTILISATEUR, 'images'), filename )
else :
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login'), code=401)
@mygallery.route('/myfiles/images/thumbnails/<filename>')
def mythumbnails(filename):
@ -52,4 +52,4 @@ def mythumbnails(filename):
return send_from_directory(
os.path.join(DOSSIER_PERSO, UTILISATEUR, 'images/thumbnails'), filename )
else :
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login'), code=401)

View File

@ -18,8 +18,6 @@ DATABASE = app.config['DATABASE']
MAIL_SERVER = app.config['MAIL_SERVER']
XMMP_SERVER = app.config['XMPP_SERVER']
SETUID = app.config['SETUID']
BASE_URL = app.config['BASE_URL']
#################################################################################################
@ -105,18 +103,17 @@ def signin(token) :
conn.commit()
flash(u'Inscription réalisée avec succés !', 'succes')
resp = redirect(url_for('loginlogout.login'))
resp = redirect(url_for('loginlogout.login', _external=True))
else:
flash(u'Les mots de passe ne sont pas identiques !', 'error')
resp = render_template('inscription.html',
signin_enable=app.config['SIGNIN_ENABLE'],
hostname=hostname)
else :
url_inscription = BASE_URL+'invitation/'+token
resp = render_template('inscription.html',
signin_enable=app.config['SIGNIN_ENABLE'],
token=token, hostname=hostname, url_inscription=url_inscription)
token=token, hostname=hostname, base_url=request.base_url)
else:
resp = redirect(BASE_URL, code=401)
resp = redirect(url_for('index', _external=True), code=401)
return resp

View File

@ -26,8 +26,6 @@ DATABASE = app.config['DATABASE']
MAIL_SERVER = app.config['MAIL_SERVER']
XMPP_SERVER = app.config['XMPP_SERVER']
SETUID = app.config['SETUID']
BASE_URL = app.config['BASE_URL']
##################################################################################################
@ -107,7 +105,7 @@ def profile() :
username=UTILISATEUR)
else :
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)
@profil.route('/profil/change-password/', methods=['GET','POST'] )
def change_passwd() :
@ -158,13 +156,13 @@ def change_passwd() :
conn.close()
return render_template('mailbox.html',
section="Profil",
section="mailbox",
address=mailbox['Mail'],
alias=mailbox['alias'],
username=UTILISATEUR)
else :
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)
@profil.route('/mymailbox/alias', methods=['GET', 'POST'] )
@ -225,7 +223,7 @@ def myalias():
username=UTILISATEUR )
else:
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)
@profil.route('/mymailbox/rmalias/<aliasrm>')
def remove_alias(aliasrm):
@ -263,7 +261,7 @@ def remove_alias(aliasrm):
return redirect(url_for('profil.myalias', _external=True))
else:
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)
@profil.route('/invitation/', methods=['GET'])
def invitation():
@ -273,18 +271,19 @@ def invitation():
cursor = conn.cursor() # Création de l'objet "curseur"
cursor.execute("""SELECT Token, invitations FROM users WHERE name=?""", (UTILISATEUR,))
tmp = cursor.fetchone()
print (tmp[0])
print (tmp)
token = tmp[0]
invitations_count = tmp[1]
conn.close()
url_invitation = BASE_URL + 'inscription/' + token
base_url = request.base_url
base_url = base_url.replace("/invitation/", "inscription")
return render_template('invitation.html',
section='Profil',
token=token,
nb_invitation=invitations_count,
token=token,
url_invitation=url_invitation)
base_url=base_url)
else:
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)
@profil.route('/gen_token/', methods=['GET'])
def generate_token():
@ -297,6 +296,7 @@ def generate_token():
(token, UTILISATEUR))
conn.commit()
conn.close()
return redirect(BASE_URL+'invitation/')
return redirect(url_for('profil.invitation', _external=True))
else:
return redirect(BASE_URL, code=401)
return redirect(url_for('loginlogout.login', _external=True), code=401)

View File

@ -1,5 +1,5 @@
from gevent.pywsgi import WSGIServer
from flask import Flask
from pywallter import create_app
app = create_app()