(this IDbContext db, string appId, UserIdentity user, CancellationToken cancellationToken)
| 7 | public static class StatsQueries |
| 8 | { |
| 9 | public static async Task<bool> HasReadAccessToApp(this IDbContext db, string appId, UserIdentity user, CancellationToken cancellationToken) |
| 10 | { |
| 11 | var cmd = new CommandDefinition( |
| 12 | @"SELECT a.id |
| 13 | FROM apps a |
| 14 | LEFT JOIN app_shares s |
| 15 | ON s.app_id = a.id |
| 16 | LEFT JOIN users u |
| 17 | ON u.id = a.owner_id |
| 18 | WHERE a.id = @appId |
| 19 | AND (a.owner_id = @userId OR s.email = @userEmail) |
| 20 | AND u.lock_reason IS NULL |
| 21 | LIMIT 1", |
| 22 | new { appId, userId = user.Id, userEmail = user.Email }, |
| 23 | cancellationToken: cancellationToken |
| 24 | ); |
| 25 | |
| 26 | var id = await db.Connection.ExecuteScalarAsync<string>(cmd); |
| 27 | return id == appId; |
| 28 | } |
| 29 | } |
no outgoing calls
no test coverage detected