mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-09 06:47:59 -06:00
JWT Authentication
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
use egui::Frame;
|
||||
use egui_tiles::Tree;
|
||||
|
||||
use crate::{
|
||||
app::{AppState, windows::WindowWrapper},
|
||||
auth::Auth,
|
||||
};
|
||||
use crate::app::{AppState, windows::WindowWrapper};
|
||||
|
||||
/// We derive Deserialize/Serialize so we can persist app state on shutdown.
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
#[serde(default)] // if we add new fields, give them default values when deserializing old state
|
||||
pub struct TemplateApp {
|
||||
auth: Auth,
|
||||
// tab: Tab,
|
||||
state: AppState,
|
||||
tree: Tree<WindowWrapper>,
|
||||
@@ -19,7 +15,6 @@ pub struct TemplateApp {
|
||||
impl Default for TemplateApp {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
auth: Auth::default(),
|
||||
state: AppState::default(),
|
||||
tree: egui_tiles::Tree::new_horizontal("tree_root", Vec::new()),
|
||||
}
|
||||
@@ -50,10 +45,10 @@ impl eframe::App for TemplateApp {
|
||||
|
||||
/// Called each time the UI needs repainting, which may be many times per second.
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
if !self.auth.logged_in() {
|
||||
if !self.state.auth.logged_in() {
|
||||
egui::CentralPanel::default()
|
||||
.frame(Frame::central_panel(&ctx.style()).inner_margin(0))
|
||||
.show(ctx, |ui| self.auth.update(ui));
|
||||
.show(ctx, |ui| self.state.auth.update(ui));
|
||||
} else {
|
||||
egui::TopBottomPanel::top("tab_panel").show(ctx, |ui| {
|
||||
// The top panel is often a good place for a menu bar:
|
||||
|
||||
@@ -3,12 +3,14 @@ mod windows;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{app::windows::WindowWrapper, config::Config, flowchart::FlowChart};
|
||||
use crate::{app::windows::WindowWrapper, auth::Auth, config::Config, flowchart::FlowChart};
|
||||
pub use app::TemplateApp;
|
||||
use egui_tiles::{TileId, Tree};
|
||||
|
||||
#[derive(Default, serde::Deserialize, serde::Serialize)]
|
||||
struct AppState {
|
||||
pub struct AppState {
|
||||
pub auth: Auth,
|
||||
|
||||
pub open_windows: HashMap<AppWindow, TileId>,
|
||||
|
||||
pub flowchart: FlowChart,
|
||||
@@ -64,7 +66,7 @@ impl AppState {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, serde::Deserialize, serde::Serialize, PartialEq, Eq, Hash)]
|
||||
enum AppWindow {
|
||||
pub enum AppWindow {
|
||||
Flowchart,
|
||||
Config,
|
||||
}
|
||||
@@ -73,7 +75,7 @@ impl AppWindow {
|
||||
fn update(&self, state: &mut AppState, ui: &mut egui::Ui) {
|
||||
match self {
|
||||
AppWindow::Flowchart => state.flowchart.paint(ui),
|
||||
AppWindow::Config => state.config.update(ui),
|
||||
AppWindow::Config => state.config.update(&mut state.auth, ui),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user