Compare commits
5 Commits
2a938d81dc
...
4b706dea9f
Author | SHA1 | Date | |
---|---|---|---|
4b706dea9f | |||
bd2e343601 | |||
85ee2b2549 | |||
154551aeaf | |||
7b10c3508a |
@@ -29,7 +29,7 @@ pub struct AppConfig {
|
|||||||
/// Unsecure : for development, bypass authentication, using the account with the given
|
/// Unsecure : for development, bypass authentication, using the account with the given
|
||||||
/// email address by default
|
/// email address by default
|
||||||
#[clap(long, env)]
|
#[clap(long, env)]
|
||||||
pub unsecure_auto_login_email: Option<String>,
|
unsecure_auto_login_email: Option<String>,
|
||||||
|
|
||||||
/// PostgreSQL database host
|
/// PostgreSQL database host
|
||||||
#[clap(long, env, default_value = "localhost")]
|
#[clap(long, env, default_value = "localhost")]
|
||||||
@@ -148,9 +148,17 @@ impl AppConfig {
|
|||||||
&ARGS
|
&ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get auto login email (if not empty)
|
||||||
|
pub fn unsecure_auto_login_email(&self) -> Option<&str> {
|
||||||
|
match self.unsecure_auto_login_email.as_deref() {
|
||||||
|
None | Some("") => None,
|
||||||
|
s => s,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Check if auth is disabled
|
/// Check if auth is disabled
|
||||||
pub fn is_auth_disabled(&self) -> bool {
|
pub fn is_auth_disabled(&self) -> bool {
|
||||||
self.unsecure_auto_login_email.is_some()
|
self.unsecure_auto_login_email().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get auth cookie domain
|
/// Get auth cookie domain
|
||||||
|
@@ -182,7 +182,7 @@ impl FromRequest for AuthExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if login is hard-coded as program argument
|
// Check if login is hard-coded as program argument
|
||||||
if let Some(email) = &AppConfig::get().unsecure_auto_login_email {
|
if let Some(email) = &AppConfig::get().unsecure_auto_login_email() {
|
||||||
let user = users_service::get_user_by_email(email).map_err(|e| {
|
let user = users_service::get_user_by_email(email).map_err(|e| {
|
||||||
log::error!("Failed to retrieve dev user: {e}");
|
log::error!("Failed to retrieve dev user: {e}");
|
||||||
ErrorPreconditionFailed("Unable to retrieve dev user!")
|
ErrorPreconditionFailed("Unable to retrieve dev user!")
|
||||||
|
@@ -38,7 +38,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
db_connection::initialize_conn().expect("Failed to connect to PostgresSQL database!");
|
db_connection::initialize_conn().expect("Failed to connect to PostgresSQL database!");
|
||||||
|
|
||||||
// Auto create default account, if requested
|
// Auto create default account, if requested
|
||||||
if let Some(mail) = &AppConfig::get().unsecure_auto_login_email {
|
if let Some(mail) = &AppConfig::get().unsecure_auto_login_email() {
|
||||||
users_service::create_or_update_user(mail, "Anonymous")
|
users_service::create_or_update_user(mail, "Anonymous")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create default account!");
|
.expect("Failed to create default account!");
|
||||||
|
@@ -111,7 +111,7 @@ dev_dependencies:
|
|||||||
flutter_launcher_icons: ^0.14.4
|
flutter_launcher_icons: ^0.14.4
|
||||||
|
|
||||||
# Generate source code
|
# Generate source code
|
||||||
build_runner: ^2.5.4
|
build_runner: ^2.6.0
|
||||||
|
|
||||||
# Riverpod code generation
|
# Riverpod code generation
|
||||||
riverpod_generator: ^2.6.5
|
riverpod_generator: ^2.6.5
|
||||||
|
@@ -280,6 +280,8 @@ function CreatedToken(p: { token: TokenWithSecret }): React.ReactElement {
|
|||||||
The API token was successfully created. Please note the following
|
The API token was successfully created. Please note the following
|
||||||
information as they won't be available next.
|
information as they won't be available next.
|
||||||
<br />
|
<br />
|
||||||
|
API URL : <CopyTextChip text={APIClient.ActualBackendURL()} />
|
||||||
|
<br />
|
||||||
Token ID: <CopyTextChip text={p.token.id.toString()} />
|
Token ID: <CopyTextChip text={p.token.id.toString()} />
|
||||||
<br />
|
<br />
|
||||||
Token value: <CopyTextChip text={p.token.token} />
|
Token value: <CopyTextChip text={p.token.token} />
|
||||||
|
Reference in New Issue
Block a user