@solidstarters/solid-core 1.2.13 → 1.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/google-authentication.controller.d.ts.map +1 -1
- package/dist/controllers/google-authentication.controller.js.map +1 -1
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +12 -1
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/crud.service.d.ts +8 -0
- package/dist/services/crud.service.d.ts.map +1 -1
- package/dist/services/crud.service.js +52 -0
- package/dist/services/crud.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/controllers/google-authentication.controller.ts +1 -2
- package/src/services/authentication.service.ts +13 -1
- package/src/services/crud.service.ts +74 -1
- package/src/workflow.readme.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15",
|
|
4
4
|
"description": "This module is a NestJS module containing all the required core providers required by a Solid application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -74,8 +74,7 @@ export class GoogleAuthenticationController {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
78
|
-
* will be passed the accessCode, using the accessCode the UI code on this page will mostly invoke the /iam/google/auth endpoint which will finally generate the JWT token.
|
|
77
|
+
* Use this endpoint to authenticate using an accessCode with Google.
|
|
79
78
|
*
|
|
80
79
|
* @param accessCode
|
|
81
80
|
* @returns
|
|
@@ -925,7 +925,19 @@ export class AuthenticationService {
|
|
|
925
925
|
await this.validateUserUsingGoogle(user);
|
|
926
926
|
|
|
927
927
|
// finally we simply generate the tokens.
|
|
928
|
-
|
|
928
|
+
const tokens = this.generateTokens(user);
|
|
929
|
+
return {
|
|
930
|
+
user: {
|
|
931
|
+
email: user.email,
|
|
932
|
+
mobile: user.mobile,
|
|
933
|
+
username: user.username,
|
|
934
|
+
forcePasswordChange: user.forcePasswordChange,
|
|
935
|
+
id: user.id,
|
|
936
|
+
roles: user.roles.map((role, idx, roles) => role.name)
|
|
937
|
+
},
|
|
938
|
+
...tokens
|
|
939
|
+
}
|
|
940
|
+
|
|
929
941
|
}
|
|
930
942
|
|
|
931
943
|
private isPasswordlessRegistrationEnabled() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BadRequestException } from "@nestjs/common";
|
|
2
2
|
import { ConfigService } from "@nestjs/config";
|
|
3
3
|
import { DiscoveryService } from "@nestjs/core";
|
|
4
|
-
import { EntityManager, QueryFailedError, SelectQueryBuilder } from "typeorm";
|
|
4
|
+
import { EntityManager, In, IsNull, Not, QueryFailedError, SelectQueryBuilder } from "typeorm";
|
|
5
5
|
import { Repository } from "typeorm/repository/Repository";
|
|
6
6
|
import { BasicFilterDto } from "../dtos/basic-filters.dto";
|
|
7
7
|
import { ComputedFieldValueType, RelationType, SelectionValueType, SolidFieldType } from "../dtos/create-field-metadata.dto";
|
|
@@ -649,4 +649,77 @@ export class CRUDService<T> { //Add two generic value i.e Person,CreatePersonDto
|
|
|
649
649
|
// return removedEntities
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
+
async recover(id: number) {
|
|
653
|
+
try {
|
|
654
|
+
const softDeletedRows = await this.repo.findOne({
|
|
655
|
+
where: {
|
|
656
|
+
//@ts-ignore
|
|
657
|
+
id, deletedAt: Not(IsNull())
|
|
658
|
+
},
|
|
659
|
+
withDeleted: true,
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
if (!softDeletedRows) {
|
|
663
|
+
throw new Error('No soft-deleted record found with the given ID.');
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
await this.repo.update(id, {
|
|
667
|
+
//@ts-ignore
|
|
668
|
+
deletedAt: null, deletedTracker: "not-deleted"
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
return { message: 'Record successfully recovered', data: softDeletedRows };
|
|
672
|
+
} catch (error) {
|
|
673
|
+
if (error instanceof QueryFailedError) {
|
|
674
|
+
if ((error as any).code === '23505') {
|
|
675
|
+
throw new Error('Another record is conflicting with the record you are attempting to Un-Archive, either delete or change the other record so as to avoid this conflict.');
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
throw new Error(error);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
async recoverMany(ids: number[]) {
|
|
684
|
+
try {
|
|
685
|
+
if (!ids || ids.length === 0) {
|
|
686
|
+
throw new Error("No IDs provided for recovery.");
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// Find soft-deleted records matching the given IDs
|
|
690
|
+
const softDeletedRows = await this.repo.find({
|
|
691
|
+
where: {
|
|
692
|
+
//@ts-ignore
|
|
693
|
+
id: In(ids),
|
|
694
|
+
deletedAt: Not(IsNull()),
|
|
695
|
+
},
|
|
696
|
+
withDeleted: true,
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
if (softDeletedRows.length === 0) {
|
|
700
|
+
throw new Error("No matching soft-deleted records found.");
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// Recover the specific records by setting deletedAt to null
|
|
704
|
+
await this.repo.update(
|
|
705
|
+
//@ts-ignore
|
|
706
|
+
{ id: In(ids) },
|
|
707
|
+
{ deletedAt: null, deletedTracker: "not-deleted" }
|
|
708
|
+
);
|
|
709
|
+
|
|
710
|
+
return { message: "Selected records successfully recovered", recoveredIds: ids };
|
|
711
|
+
} catch (error) {
|
|
712
|
+
if (error instanceof QueryFailedError) {
|
|
713
|
+
if ((error as any).code === "23505") {
|
|
714
|
+
throw new Error(
|
|
715
|
+
"Another record is conflicting with the record you are attempting to Un-Archive, either delete or change the other record to avoid this conflict."
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
throw new Error(error);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
|
|
652
725
|
}
|
package/src/workflow.readme.md
CHANGED
|
@@ -10,7 +10,7 @@ Let's say that:
|
|
|
10
10
|
3. The backend redirects the tab to the Google login page where the user logs in.
|
|
11
11
|
4. Once done, Google redirects the tab to the backend URL: https://solid.website.com/api/iam/google/connect/callback. When this callback comes, it comes with the users profile & access token.
|
|
12
12
|
5. Then, the backend redirects the tab to the url of your choice with the param accessCode (example: http://website.com/connect/google/dummy-redirect?accessCode=eyfvg).
|
|
13
|
-
6. The frontend (http://website.com/connect/google/dummy-redirect) calls the backend with https://solid.website.com/api/iam/google/
|
|
13
|
+
6. The frontend (http://website.com/connect/google/dummy-redirect) calls the backend with https://solid.website.com/api/iam/google/authenticate?accessCode=eyfvg that returns the Solid user profile with its jwt.
|
|
14
14
|
(Under the hood, the backend asks Google for the user's profile and a match is done on Google user's email address and Solid user's email address).
|
|
15
15
|
7. The frontend now possesses the user's jwt, which means the user is connected and the frontend can make authenticated requests to the backend!
|
|
16
16
|
|