diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-26 01:43:12 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-26 01:43:12 -0500 |
commit | cc5a3f9056fe1b563dbb40d51b1621769150c08d (patch) | |
tree | 127bb50ebb622783e4529764b6a2735cef1eb8c1 /teleterm-web/src/model.rs | |
parent | 81fc5c6a2c6df38025961945cb496ccc4d432036 (diff) | |
download | teleterm-cc5a3f9056fe1b563dbb40d51b1621769150c08d.tar.gz teleterm-cc5a3f9056fe1b563dbb40d51b1621769150c08d.zip |
add a logout button
Diffstat (limited to 'teleterm-web/src/model.rs')
-rw-r--r-- | teleterm-web/src/model.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/teleterm-web/src/model.rs b/teleterm-web/src/model.rs index 9c611b6..05e3152 100644 --- a/teleterm-web/src/model.rs +++ b/teleterm-web/src/model.rs @@ -120,8 +120,18 @@ impl Model { } }, crate::Msg::StopWatching => { + log::debug!("stop watching"); self.list(orders); } + crate::Msg::Logout => { + log::debug!("logout"); + self.logout(orders); + } + crate::Msg::LoggedOut(..) => { + log::debug!("logged out"); + self.config.username = None; + self.state = State::Login; + } } } @@ -201,6 +211,13 @@ impl Model { self.state = State::Watch(WatchConn::new(ws)); } + fn logout(&self, orders: &mut impl Orders<crate::Msg>) { + let url = format!("http://{}/logout", self.config.public_address); + orders.perform_cmd( + seed::Request::new(url).fetch(crate::Msg::LoggedOut), + ); + } + fn process(&mut self, bytes: &[u8]) { if let State::Watch(conn) = &mut self.state { conn.term.process(bytes); |