Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/get detailed door access #265

Merged
merged 21 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ LOGLEVEL=debug

PORT=3000

Cors origins, ges av en kommaseparerad lista
#ALLOWED_ORIGINS=
#Cors origins, ges av en kommaseparerad lista
ALLOWED_ORIGINS=

# Auth stuff
JWT_SECRET=blabla
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Alla märkbara ändringar ska dokumenteras i denna fil.
Baserat på [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
och följer [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.6.0] - 2023-12-04
la till ny gql metod: allUsersWithIndividualAccess

## [1.5.0] - 2023-11-26
Adds ledtoa as a door

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ekorre-ts",
"version": "1.4.0",
"version": "1.6.0",
"description": "E-Sektionens backend",
"main": "src/index.ts",
"scripts": {
Expand Down
24 changes: 24 additions & 0 deletions src/api/user.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import {
} from '../errors/request.errors';
import prisma from './prisma';

type UserWithAccess = Prisma.PrismaUserGetPayload<{
include: {
access: true;
};
}>;

const logger = Logger.getLogger('UserAPI');
const defaultOrder: Prisma.PrismaUserOrderByWithRelationAndSearchRelevanceInput[] = [
{
Expand Down Expand Up @@ -199,6 +205,24 @@ export class UserAPI {
return count;
}
}
/**
*
* @returns All users with individual access
*/
async getUsersWithIndividualAccess(): Promise<UserWithAccess[]> {
const users = await prisma.prismaUser.findMany({
//filters out users with empty access
where: {
access: {
some: {},
},
},
afroborg marked this conversation as resolved.
Show resolved Hide resolved
include: {
access: true,
},
});
return users;
}

/**
* Ensures a login is correct, and if so returns the user
Expand Down
Loading
Loading