-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ecolabdata/feat/connection-step
Add connection step
- Loading branch information
Showing
10 changed files
with
140 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from functools import wraps | ||
|
||
from flask import abort, flash, session, url_for | ||
from flask import redirect as flask_redirect | ||
|
||
|
||
def authenticated(redirect: bool = True): | ||
def decorator(f): | ||
@wraps(f) | ||
def decorated_function(*args, **kwargs): | ||
if not all(k in session for k in ("url", "username", "password")): | ||
if redirect: | ||
flash("Pas d'information de connexion trouvée en session", "error") | ||
return flask_redirect(url_for("login_form")) | ||
else: | ||
abort(401, "Pas d'information de connexion trouvée en session") | ||
return f(*args, **kwargs) | ||
|
||
return decorated_function | ||
|
||
return decorator | ||
|
||
|
||
def connection_infos() -> tuple[str, str, str]: | ||
return session["url"], session["username"], session["password"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% extends "base.html.j2" %} | ||
{% block content %} | ||
<div class="fr-stepper fr-mt-4v"> | ||
<h2 class="fr-stepper__title"> | ||
Connexion au catalogue | ||
<span class="fr-stepper__state">Étape 1 sur 4</span> | ||
</h2> | ||
<div class="fr-stepper__steps" data-fr-current-step="1" data-fr-steps="4"></div> | ||
<p class="fr-stepper__details"> | ||
<span class="fr-text--bold">Étape suivante :</span> Sélection des données | ||
</p> | ||
</div> | ||
<form method="post" action="{{ url_for('login') }}"> | ||
<div class="fr-input-group"> | ||
<label class="fr-label" for="query">URL du catalogue * | ||
<span class="fr-hint-text">Ex : https://www.example.com/geonetwork/srv</span> | ||
</label> | ||
<input required class="fr-input" type="url" id="url" name="url" value="{{ url }}" /> | ||
</div> | ||
<div class="fr-input-group"> | ||
<label class="fr-label" for="username">Identifiant sur le catalogue *</label> | ||
<input required class="fr-input" type="text" id="username" name="username" value="{{ username }}" /> | ||
</div> | ||
<div class="fr-input-group"> | ||
<label class="fr-label" for="password">Mot de passe sur le catalogue *</label> | ||
<input required class="fr-input" type="password" id="password" name="password" value="{{ password }}" /> | ||
</div> | ||
<div class="fr-hint-text">Les données de ce formulaire sont chiffrées et stockées uniquement sur votre navigateur.</div> | ||
<div class="fr-mt-2w fr-grid-row"> | ||
<button type="submit" class="fr-btn">Suivant</button> | ||
</div> | ||
</form> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters