news_flash/models/
login_gui.rs1use std::fmt::Debug;
2
3use super::ApiSecret;
4use crate::models::Url;
5
6type LoginUrlFn = dyn Fn(Option<&ApiSecret>) -> Option<Url>;
7
8#[derive(Debug)]
9pub enum LoginGUI {
10 Direct(DirectLoginGUI),
11 OAuth(Box<OAuthLoginGUI>),
12 None,
13}
14
15pub struct OAuthLoginGUI {
16 pub login_website: Box<LoginUrlFn>,
17 pub catch_redirect: Option<String>,
18 pub custom_api_secret: bool,
19 pub custom_api_secret_url: Option<Url>,
20 pub embeded_api_secret: bool,
21 pub create_secret_url: Option<Url>,
22}
23
24impl Debug for OAuthLoginGUI {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 f.debug_struct("OAuthLoginGUI")
27 .field("catch_redirect", &self.catch_redirect)
28 .field("custom_api_secret", &self.custom_api_secret)
29 .field("custom_api_secret_url", &self.custom_api_secret_url)
30 .field("embeded_api_secret", &self.embeded_api_secret)
31 .field("create_secret_url", &self.create_secret_url)
32 .finish()
33 }
34}
35
36#[derive(Clone, Debug)]
37pub struct DirectLoginGUI {
38 pub url: bool,
39 pub support_token_login: bool,
40 pub http_auth: bool,
41}
42
43impl Default for DirectLoginGUI {
44 fn default() -> Self {
45 Self {
46 url: true,
47 support_token_login: false,
48 http_auth: false,
49 }
50 }
51}