2026-03-13 15:17:15 -07:00
|
|
|
"""Auth routes - login, logout, password change"""
|
|
|
|
|
|
|
|
|
|
from flask import Blueprint, render_template, request, redirect, url_for, session, flash, jsonify
|
|
|
|
|
from web.auth import check_password, hash_password, load_credentials, save_credentials
|
|
|
|
|
|
|
|
|
|
auth_bp = Blueprint('auth', __name__)
|
|
|
|
|
|
|
|
|
|
|
2026-07-13 15:45:47 -07:00
|
|
|
# Login is disabled — AutarchOS is a single-user appliance. The endpoints
|
|
|
|
|
# below are kept so existing url_for('auth.*') calls and the companion app
|
|
|
|
|
# API still resolve; they auto-grant a session.
|
|
|
|
|
|
2026-03-13 15:17:15 -07:00
|
|
|
@auth_bp.route('/login', methods=['GET', 'POST'])
|
|
|
|
|
def login():
|
2026-07-13 15:45:47 -07:00
|
|
|
session['user'] = 'admin'
|
|
|
|
|
next_url = request.args.get('next') or url_for('dashboard.index')
|
|
|
|
|
return redirect(next_url)
|
2026-03-13 15:17:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@auth_bp.route('/api/login', methods=['POST'])
|
|
|
|
|
def api_login():
|
2026-07-13 15:45:47 -07:00
|
|
|
session['user'] = 'admin'
|
|
|
|
|
return jsonify({'ok': True, 'user': 'admin'})
|
2026-03-13 15:17:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@auth_bp.route('/api/check', methods=['GET'])
|
|
|
|
|
def api_check():
|
2026-07-13 15:45:47 -07:00
|
|
|
return jsonify({'ok': True, 'user': session.get('user', 'admin')})
|
2026-03-13 15:17:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@auth_bp.route('/logout')
|
|
|
|
|
def logout():
|
2026-07-13 15:45:47 -07:00
|
|
|
# No-op: logout makes no sense without a login wall. Bounce home.
|
|
|
|
|
return redirect(url_for('dashboard.index'))
|