user login part 2
This commit is contained in:
parent
c18f7735f5
commit
6010b76309
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,3 +14,4 @@ library/data/*.csv
|
||||
library/data/*.seg
|
||||
library/data/MAIN_WRITELOCK
|
||||
library/files/*.pdf
|
||||
settings_development.toml
|
||||
|
@ -80,6 +80,8 @@ def index_books(filename: str, image_folder: str):
|
||||
|
||||
def settings_from_file():
|
||||
settings = {}
|
||||
if os.path.isfile("settings_development.toml"):
|
||||
with open("settings_development.toml", "rb") as settings_file:
|
||||
return tomllib.load(settings_file)
|
||||
with open("settings.toml", "rb") as settings_file:
|
||||
settings = tomllib.load(settings_file)
|
||||
return settings
|
||||
return tomllib.load(settings_file)
|
||||
|
@ -11,7 +11,7 @@ from sqlalchemy.exc import (
|
||||
InterfaceError,
|
||||
InvalidRequestError,
|
||||
)
|
||||
from usermodel import User
|
||||
from application.models.usermodel import User
|
||||
|
||||
|
||||
def ForgotPassword(mail):
|
||||
|
@ -2,7 +2,7 @@ from flask import abort, flash, redirect, render_template, request, url_for
|
||||
from flask_bcrypt import check_password_hash
|
||||
from flask_login import login_user
|
||||
from forms.loginform import LoginForm
|
||||
from usermodel import User
|
||||
from application.models.usermodel import User
|
||||
|
||||
|
||||
def LoginUser():
|
||||
@ -26,4 +26,4 @@ def LoginUser():
|
||||
return render_template("login.html", loginform=loginform)
|
||||
except Exception as e:
|
||||
flash(e, "danger")
|
||||
return render_template("login.html", loginform=loginform)
|
||||
return render_template("user/login.html", loginform=loginform)
|
||||
|
@ -10,7 +10,7 @@ from sqlalchemy.exc import (
|
||||
InterfaceError,
|
||||
InvalidRequestError,
|
||||
)
|
||||
from usermodel import User
|
||||
from application.models.usermodel import User
|
||||
from werkzeug.routing import BuildError
|
||||
|
||||
|
||||
@ -62,4 +62,4 @@ def RegisterUser():
|
||||
db.session.rollback()
|
||||
registerform.email.errors.append("Unknown error occured!")
|
||||
flash("An error occured !", "danger")
|
||||
return render_template("register.html", registerform=registerform)
|
||||
return render_template("user/register.html", registerform=registerform)
|
||||
|
@ -12,7 +12,7 @@ from sqlalchemy.exc import (
|
||||
InterfaceError,
|
||||
InvalidRequestError,
|
||||
)
|
||||
from usermodel import User
|
||||
from application.models.usermodel import User
|
||||
from werkzeug.routing import BuildError
|
||||
|
||||
|
||||
|
@ -9,6 +9,11 @@ import os
|
||||
import bcrypt
|
||||
from app import create_app, login_manager
|
||||
from application.csvparser import CsvParser
|
||||
from application.user.loginuser import LoginUser
|
||||
from application.user.registeruser import RegisterUser
|
||||
from application.user.forgotpassword import ForgotPassword
|
||||
from application.user.resetpassword import ResetPassword
|
||||
|
||||
from flask import Blueprint, redirect, render_template, request, session
|
||||
from flask_wtf.csrf import CSRFProtect, CSRFError
|
||||
from flask_login import (
|
||||
@ -24,6 +29,8 @@ from requests import get
|
||||
from search import search
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
|
||||
APP = create_app()
|
||||
csrf = CSRFProtect()
|
||||
csrf.init_app(APP)
|
||||
|
@ -179,3 +179,12 @@ a:active { text-decoration: none; }
|
||||
margin: 3em 1em 1em 1em;
|
||||
}
|
||||
}
|
||||
div#auth_buttons{
|
||||
position: fixed;
|
||||
top: 0.5em;
|
||||
right: 0.5em;
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
@ -4,6 +4,26 @@
|
||||
<nav id="nav" class="container">
|
||||
{% include 'menu.html' %}
|
||||
</nav>
|
||||
<div id="auth_buttons">
|
||||
{% if not current_user.is_authenticated %}
|
||||
<div class="signin">
|
||||
<a href="/login">
|
||||
<input type="button" name="button" value="Sign in"></input>
|
||||
</a>
|
||||
</div>
|
||||
<div class="signin">
|
||||
<a href="/register">
|
||||
<input type="button" name="button" value="Register"></input>
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="logout">
|
||||
<a href="/logout">
|
||||
<input type="button" name="button" value="Logout"></input>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="bookshelf">
|
||||
{% for id, pubinfo in publications.items() %}
|
||||
<div id="{{ id }}" class='book filter {{ pubinfo["Type"] }} {{ pubinfo["Year"] }} {{ pubinfo["License"] }}'>
|
||||
|
Loading…
Reference in New Issue
Block a user