feat: allow restrict Pomodoro via password
- introduce password flag in server command line options - update clientCommand model - add password requirement for controlling the Pomodoro timer - document password in README
This commit is contained in:
parent
8deb642a7e
commit
f991ba885d
5 changed files with 38 additions and 26 deletions
|
@ -30,26 +30,28 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
continue
|
||||
}
|
||||
|
||||
// Process the command
|
||||
switch clientCommand.Command {
|
||||
case "start":
|
||||
if !pomodoro.IsPomodoroOngoing() {
|
||||
if clientCommand.Config != shared.UnsetPomodoroConfig {
|
||||
pomodoroConfig = clientCommand.Config
|
||||
// Process the command if pomodoro password matches
|
||||
if clientCommand.Password == shared.PomodoroPassword {
|
||||
switch clientCommand.Command {
|
||||
case "start":
|
||||
if !pomodoro.IsPomodoroOngoing() {
|
||||
if clientCommand.Config != shared.UnsetPomodoroConfig {
|
||||
pomodoroConfig = clientCommand.Config
|
||||
}
|
||||
go pomodoro.RunPomodoro(pomodoroConfig) // Start the timer with the list of clients
|
||||
}
|
||||
case "stop":
|
||||
if pomodoro.IsPomodoroOngoing() {
|
||||
pomodoro.ResetPomodoro() // Reset Pomodoro
|
||||
}
|
||||
case "pause":
|
||||
if pomodoro.IsPomodoroOngoing() && !pomodoro.IsPomodoroPaused() {
|
||||
pomodoro.PausePomodoro() // Pause the timer
|
||||
}
|
||||
case "resume":
|
||||
if pomodoro.IsPomodoroOngoing() && pomodoro.IsPomodoroPaused() {
|
||||
pomodoro.ResumePomodoro() // Resume the timer
|
||||
}
|
||||
go pomodoro.RunPomodoro(pomodoroConfig) // Start the timer with the list of clients
|
||||
}
|
||||
case "stop":
|
||||
if pomodoro.IsPomodoroOngoing() {
|
||||
pomodoro.ResetPomodoro() // Reset Pomodoro
|
||||
}
|
||||
case "pause":
|
||||
if pomodoro.IsPomodoroOngoing() && !pomodoro.IsPomodoroPaused() {
|
||||
pomodoro.PausePomodoro() // Pause the timer
|
||||
}
|
||||
case "resume":
|
||||
if pomodoro.IsPomodoroOngoing() && pomodoro.IsPomodoroPaused() {
|
||||
pomodoro.ResumePomodoro() // Resume the timer
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue