Rename
This commit is contained in:
parent
c084b2c820
commit
1155e226ab
6 changed files with 29 additions and 12 deletions
|
@ -1,2 +1,3 @@
|
|||
# lotosa
|
||||
# LaToSa
|
||||
LaToSa is a backend for [SaToSa](https://github.com/IdentityPython/SATOSA) and allows you to use local accounts for authentication
|
||||
|
||||
|
|
16
app.py
16
app.py
|
@ -6,7 +6,7 @@ from flask import (Flask, flash, redirect, render_template, request,
|
|||
from flask_login import LoginManager, login_required, login_user, logout_user
|
||||
|
||||
from forms import LoginForm
|
||||
from lotosa import LoToSa
|
||||
from latosa import LaToSa
|
||||
from user import User
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -19,12 +19,12 @@ app.config.update(
|
|||
login_manager = LoginManager()
|
||||
login_manager.init_app(app)
|
||||
|
||||
lotosa = LoToSa(app)
|
||||
latosa = LaToSa(app)
|
||||
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id) -> Union[User, None]:
|
||||
for user in lotosa.get_users():
|
||||
for user in latosa.get_users():
|
||||
if user.uid == user_id:
|
||||
return user
|
||||
return None
|
||||
|
@ -32,24 +32,24 @@ def load_user(user_id) -> Union[User, None]:
|
|||
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
def index():
|
||||
i18n = lotosa.get_i18n(request)
|
||||
i18n = latosa.get_i18n(request)
|
||||
form = LoginForm()
|
||||
if request.method == 'POST':
|
||||
username = form.username.data
|
||||
password = form.password.data
|
||||
user = lotosa.login_user(username, password)
|
||||
user = latosa.login_user(username, password)
|
||||
if user:
|
||||
login_user(user)
|
||||
flash('Logged in successfully.')
|
||||
flash(i18n['login']['success'])
|
||||
return redirect(url_for('admin'))
|
||||
flash('Logged in faled, please try again.')
|
||||
flash(i18n['login']['failed'])
|
||||
return render_template('index.html', i18n=i18n, form=form)
|
||||
|
||||
|
||||
@app.route('/admin', methods=['GET'])
|
||||
@login_required
|
||||
def admin():
|
||||
i18n = lotosa.get_i18n(request)
|
||||
i18n = latosa.get_i18n(request)
|
||||
return render_template('admin.html', i18n=i18n)
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
head:
|
||||
title: LoToSA
|
||||
title: LaToSa
|
||||
|
||||
body:
|
||||
h1: LoToSA
|
||||
h1: Local Auth to SAML
|
||||
|
||||
login:
|
||||
failed: Login failed, please try again.
|
||||
success: Login successful.
|
||||
|
|
|
@ -7,7 +7,7 @@ from flask import Flask, request
|
|||
from user import User
|
||||
|
||||
|
||||
class LoToSa:
|
||||
class LaToSa:
|
||||
|
||||
def __init__(self, app: Flask):
|
||||
self.users = [
|
|
@ -0,0 +1,3 @@
|
|||
ul {
|
||||
list-style-type: none;
|
||||
}
|
|
@ -13,6 +13,15 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li class="notice">{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% block content %}
|
||||
<h1>{{i18n.body.h1}}</h1>
|
||||
<form action="" method="post" novalidate>
|
||||
|
|
Loading…
Add table
Reference in a new issue