(
&self,
ctx: &Context<'_>,
input: CreateGithubSessionInput,
)
| 229 | #[Object] |
| 230 | impl MutationRoot { |
| 231 | async fn create_github_session( |
| 232 | &self, |
| 233 | ctx: &Context<'_>, |
| 234 | input: CreateGithubSessionInput, |
| 235 | ) -> Result<CreateSessionPayload> { |
| 236 | log::info!("creating GitHub session: {:?}", input); |
| 237 | let store = ctx.data_unchecked::<Store>(); |
| 238 | |
| 239 | if store.server_secret != input.server_secret { |
| 240 | log::warn!("server secret did not match secret provided by client"); |
| 241 | return Err(Error::Auth("failed to authenticate request".to_string())); |
| 242 | } |
| 243 | |
| 244 | let result = store.upsert_session(input).await?; |
| 245 | log::info!( |
| 246 | "server secret matched secret provided by client, user session created: {:?}", |
| 247 | result.user |
| 248 | ); |
| 249 | |
| 250 | Ok(CreateSessionPayload { |
| 251 | alerts: result.alerts.iter().map(alert::Alert::from).collect_vec(), |
| 252 | user_edge: Some(UserEdge { |
| 253 | cursor: String::from("0"), |
| 254 | node: User::from(&result.user), |
| 255 | }), |
| 256 | session_edge: Some(SessionEdge { |
| 257 | cursor: String::from("0"), |
| 258 | node: Session { |
| 259 | id: result.session_id, |
| 260 | }, |
| 261 | }), |
| 262 | }) |
| 263 | } |
| 264 | |
| 265 | async fn delete_account( |
| 266 | &self, |
nothing calls this directly
no test coverage detected