(&mut self, token: String)
| 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 { |
no test coverage detected