Added login
This commit is contained in:
parent
d94d060ca4
commit
b57341448b
3 changed files with 51 additions and 6 deletions
|
@ -34,6 +34,8 @@ log.info('Starting saturn')
|
|||
|
||||
davclient = get_davclient(config['caldav'])
|
||||
app = create_app(
|
||||
bytes(config.get('server', 'secret_key'), 'utf-8'),
|
||||
config.get('server', 'password'),
|
||||
davclient,
|
||||
)
|
||||
|
||||
|
|
|
@ -5,17 +5,33 @@ from ..calendar import get_events
|
|||
|
||||
|
||||
def create_app(
|
||||
secret_key,
|
||||
password,
|
||||
davclient,
|
||||
):
|
||||
app = flask.Flask(__name__)
|
||||
app.secret_key = secret_key
|
||||
|
||||
@app.route('/')
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
def home():
|
||||
events = get_events(davclient)
|
||||
if flask.request.method == 'POST':
|
||||
if flask.request.form.get('password') == password:
|
||||
flask.session['logged'] = True
|
||||
else: flask.session['failed'] = True
|
||||
return flask.redirect(flask.url_for('home'))
|
||||
|
||||
return flask.render_template(
|
||||
'index.html',
|
||||
events = events,
|
||||
)
|
||||
if flask.session.get('logged', False):
|
||||
events = get_events(davclient)
|
||||
return flask.render_template(
|
||||
'index.html',
|
||||
events = events,
|
||||
)
|
||||
else:
|
||||
failed = flask.session.get('failed', False)
|
||||
if failed: flask.session['failed'] = False
|
||||
return flask.render_template(
|
||||
'login.html',
|
||||
failed = failed,
|
||||
)
|
||||
|
||||
return app
|
||||
|
|
|
@ -1,21 +1,48 @@
|
|||
:root {
|
||||
--ui-background: white;
|
||||
--ui-01: var(--gray-10);
|
||||
--ui-04: var(--gray-50);
|
||||
|
||||
--text-01: var(--gray-100);
|
||||
--text-02: var(--gray-70);
|
||||
--text-03: var(--gray-40);
|
||||
--text-04: white;
|
||||
|
||||
--link-01: var(--blue-60);
|
||||
|
||||
--interactive-01: var(--blue-60);
|
||||
|
||||
--field-01: var(--gray-10);
|
||||
--danger-02: var(--red-60);
|
||||
|
||||
--hover-primary: var(--blue-60-hover);
|
||||
--hover-primary-text: var(--blue-70);
|
||||
--hover-ui: var(--gray-10-hover);
|
||||
|
||||
--active-primary: var(--blue-80);
|
||||
--active-ui: var(--gray-30);
|
||||
|
||||
--focus: var(--blue-60);
|
||||
|
||||
--visited-link: var(--purple-60);
|
||||
|
||||
|
||||
--gray-10: #f4f4f4;
|
||||
--gray-10-hover: #e5e5e5;
|
||||
--gray-30: #c6c6c6;
|
||||
--gray-40: #a8a8a8;
|
||||
--gray-50: #8d8d8d;
|
||||
--gray-70: #525252;
|
||||
--gray-100: #161616;
|
||||
|
||||
--blue-60: #0f62fe;
|
||||
--blue-60-hover: #0353e9;
|
||||
--blue-70: #0043ce;
|
||||
--blue-80: #002d9c;
|
||||
|
||||
--purple-60: #8a3ffc;
|
||||
|
||||
--red-60: #da1e28;
|
||||
}
|
||||
|
||||
body {
|
||||
|
|
Reference in a new issue