MCPcopy Create free account
hub / github.com/Botloader/botloader / do_login

Method do_login

components/webapi/src/routes/ws.rs:178–204  ·  view source on GitHub ↗
(&mut self, token: String)

Source from the content-addressed store, hash-verified

176 }
177
178 async fn do_login(&mut self, token: String) -> WsResult {
179 if let Some(session) = self
180 .app_state
181 .db
182 .get_session(&token)
183 .await
184 .map_err(|_| WsCloseReason::InternalError)?
185 {
186 let api_client = self
187 .app_state
188 .oauth_api_client_cache
189 .fetch(session.user.id, &session.oauth_token.access_token);
190
191 let logged_in_session = LoggedInSession::new(session, api_client);
192
193 self.send_event(WsEvent::AuthSuccess(logged_in_session.session.user.clone()))
194 .await?;
195
196 self.state = WsState::Authorized(AuthorizedWsState {
197 session: logged_in_session,
198 });
199
200 Ok(())
201 } else {
202 Err(WsCloseReason::BadToken)
203 }
204 }
205
206 async fn handle_ws_command_auth(&mut self, cmd: WsCommand) -> WsResult {
207 match cmd {

Callers 1

Calls 3

get_sessionMethod · 0.80
fetchMethod · 0.65
send_eventMethod · 0.45

Tested by

no test coverage detected