-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/add-aws-ses-provider
- Loading branch information
Showing
11 changed files
with
4,607 additions
and
4,371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,13 +27,6 @@ Note: Only users with `Admin` role get list of all keys. Returns `null` for user | |
mutation LoginUser { | ||
login(loginUserInput: { username: "admin", password: "mysecurepassword" }) { | ||
token | ||
user | ||
allKeys { | ||
apiKeyId | ||
apiKey | ||
applicationId | ||
status | ||
} | ||
__typename | ||
} | ||
} | ||
|
@@ -42,9 +35,9 @@ mutation LoginUser { | |
**cURL** | ||
|
||
```sh | ||
curl --location 'http://localhost:3000/graphql' \ | ||
curl --location 'localhost:3000/graphql' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-raw '{"query":"mutation LoginUser {\n login(loginUserInput: { username: \"admin\", password: \"mysecurepassword\" }) {\n token\n user\n allKeys {\n apiKeyId\n apiKey\n applicationId\n status\n }\n __typename\n }\n}","variables":{}}' | ||
--data '{"query":"mutation LoginUser {\n login(loginUserInput: { username: \"admin\", password: \"mysecurepassword\" }) {\n token\n __typename\n }\n}","variables":{}}' | ||
``` | ||
|
||
**Sample response** | ||
|
@@ -53,22 +46,7 @@ curl --location 'http://localhost:3000/graphql' \ | |
{ | ||
"data": { | ||
"login": { | ||
"token": "mysecuretoken", | ||
"user": "admin", | ||
"allKeys": [ | ||
{ | ||
"apiKeyId": 1, | ||
"apiKey": "test-api-key", | ||
"applicationId": 1, | ||
"status": 1 | ||
}, | ||
{ | ||
"apiKeyId": 2, | ||
"apiKey": "test-api-key-2", | ||
"applicationId": 2, | ||
"status": 1 | ||
} | ||
], | ||
"token": "eymysecuretoken", | ||
"__typename": "LoginResponse" | ||
} | ||
} | ||
|
@@ -186,7 +164,7 @@ query { | |
sortBy: "createdOn" | ||
sortOrder: DESC | ||
search: "[email protected]" | ||
filters: [{ field: "channelType", operator: "eq", value: "1" }] | ||
filters: [{ field: "applicationId", operator: "eq", value: "1" }] | ||
} | ||
) { | ||
notifications { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
apps/portal/src/app/views/applications/application.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export interface Application { | ||
applicationId: number; | ||
name: string; | ||
userId: number; | ||
createdOn: Date; | ||
updatedOn: Date; | ||
status: number; | ||
} | ||
|
||
export interface ApplicationResponse { | ||
applications: Application[]; | ||
total: number; | ||
offset: number; | ||
limit: number; | ||
} |
61 changes: 61 additions & 0 deletions
61
apps/portal/src/app/views/applications/applications.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, catchError, map } from 'rxjs'; | ||
import { GraphqlService } from 'src/app/graphql/graphql.service'; | ||
import { GetApplications } from 'src/app/graphql/graphql.queries'; | ||
import { ApolloQueryResult } from '@apollo/client/core'; | ||
import { Application, ApplicationResponse } from './application.model'; | ||
|
||
interface GetApplicationsResponse { | ||
applications: { | ||
applications?: Application[]; | ||
total?: number; | ||
offset?: number; | ||
limit?: number; | ||
}; | ||
} | ||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class ApplicationsService { | ||
constructor(private graphqlService: GraphqlService) {} | ||
|
||
getApplications(variables, inputToken): Observable<ApplicationResponse> { | ||
return this.graphqlService.query(GetApplications, variables, inputToken).pipe( | ||
map((response: ApolloQueryResult<GetApplicationsResponse>) => { | ||
const applicationArray = response.data?.applications.applications; | ||
|
||
const applicationResponseObject: ApplicationResponse = { | ||
applications: applicationArray, | ||
total: response.data?.applications.total, | ||
offset: response.data?.applications.offset, | ||
limit: response.data?.applications.limit, | ||
}; | ||
return applicationResponseObject; | ||
}), | ||
catchError((error) => { | ||
const errorMessage: string = error.message; | ||
throw new Error(errorMessage); | ||
}), | ||
); | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
decodeToken(token: string): string { | ||
try { | ||
// Split the JWT token into its parts (Header, Payload, Signature) | ||
const tokenArray = token.split('.'); | ||
|
||
if (tokenArray.length !== 3) { | ||
throw new Error('Invalid JWT token'); | ||
} | ||
|
||
// Decode the payload (the second part of the token) | ||
const decodedPayload = atob(tokenArray[1]); | ||
|
||
// Parse the decoded payload as JSON | ||
return JSON.parse(decodedPayload); | ||
} catch (error) { | ||
throw new Error(`Error decoding token payload: ${error.message}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.