mirror of
https://github.com/apognu/tuigreet.git
synced 2024-09-11 07:25:29 +03:00
Short-circuit authentication if no command was configured (#140).
This commit is contained in:
parent
4ac12261cc
commit
e203bee7ec
@ -21,6 +21,7 @@ new_command = New command:
|
||||
shutdown = Shut down
|
||||
reboot = Reboot
|
||||
|
||||
command_missing = No command configured
|
||||
command_exited = Command exited with
|
||||
command_failed = Command failed
|
||||
|
||||
|
@ -21,6 +21,7 @@ command = Nouvelle commande :
|
||||
shutdown = Éteindre
|
||||
reboot = Redémarrer
|
||||
|
||||
command_missing = Aucune commande configurée
|
||||
command_exited = La commande a retourné
|
||||
command_failed = Échec de la commande
|
||||
|
||||
|
50
src/ipc.rs
50
src/ipc.rs
@ -148,29 +148,43 @@ impl Ipc {
|
||||
} else {
|
||||
tracing::info!("authentication successful, starting session");
|
||||
|
||||
let command = greeter.session_source.command(greeter).map(str::to_string);
|
||||
match greeter.session_source.command(greeter).map(str::to_string) {
|
||||
None => {
|
||||
Ipc::cancel(greeter).await;
|
||||
|
||||
if let Some(command) = command {
|
||||
greeter.done = true;
|
||||
greeter.mode = Mode::Processing;
|
||||
greeter.message = Some(fl!("command_missing"));
|
||||
greeter.reset(false).await;
|
||||
}
|
||||
|
||||
let session = Session::get_selected(greeter);
|
||||
let (command, env) = wrap_session_command(greeter, session, &command);
|
||||
Some(command) if command.is_empty() => {
|
||||
Ipc::cancel(greeter).await;
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
self.send(Request::StartSession { cmd: vec![command.to_string()], env }).await;
|
||||
greeter.message = Some(fl!("command_missing"));
|
||||
greeter.reset(false).await;
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
let _ = command;
|
||||
let _ = env;
|
||||
Some(command) => {
|
||||
greeter.done = true;
|
||||
greeter.mode = Mode::Processing;
|
||||
|
||||
self
|
||||
.send(Request::StartSession {
|
||||
cmd: vec!["true".to_string()],
|
||||
env: vec![],
|
||||
})
|
||||
.await;
|
||||
let session = Session::get_selected(greeter);
|
||||
let (command, env) = wrap_session_command(greeter, session, &command);
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
self.send(Request::StartSession { cmd: vec![command.to_string()], env }).await;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
let _ = command;
|
||||
let _ = env;
|
||||
|
||||
self
|
||||
.send(Request::StartSession {
|
||||
cmd: vec!["true".to_string()],
|
||||
env: vec![],
|
||||
})
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user