(&self, (user_id, session_id): (String, String))
| 131 | } |
| 132 | |
| 133 | pub async fn authenticate(&self, (user_id, session_id): (String, String)) -> Viewer { |
| 134 | let result = sqlx::query_as::<_, SessionRow>( |
| 135 | "select |
| 136 | u.id user_id, |
| 137 | u.selected_repository_id, |
| 138 | $2 session_id, |
| 139 | array_agg(ur.repository_id) write_repo_ids |
| 140 | |
| 141 | from sessions s |
| 142 | join users u on s.user_id = u.id |
| 143 | join users_repositories ur on u.id = ur.user_id |
| 144 | where s.user_id = $1::uuid and s.session_id = decode($2, 'hex') |
| 145 | and ur.can_write |
| 146 | group by u.id", |
| 147 | ) |
| 148 | .bind(&user_id) |
| 149 | .bind(&session_id) |
| 150 | .fetch_optional(&self.pool) |
| 151 | .await; |
| 152 | |
| 153 | match result { |
| 154 | Ok(row) => (user_id, row).into(), |
| 155 | |
| 156 | Err(err) => { |
| 157 | log::warn!("failed to fetch session info, proceeding as guest: {}", err); |
| 158 | Viewer::guest() |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | #[Object] |
no outgoing calls
no test coverage detected