diff --git a/api/src/data/migrations/029.drop_auth_index.ts b/api/src/data/migrations/029.drop_auth_index.ts
new file mode 100644
index 0000000..2799dc5
--- /dev/null
+++ b/api/src/data/migrations/029.drop_auth_index.ts
@@ -0,0 +1,15 @@
+import * as knex from "knex";
+
+export async function up(knex: knex.Knex) {
+ return knex.schema.alterTable("users", (table) => {
+ table.dropChecks("unique_users_auth_subject")
+ });
+}
+
+export async function down(knex: knex.Knex) {
+ return knex.schema.alterTable("users", (table) => {
+ table.unique(["auth_subject"], {
+ indexName: "unique_users_auth_subject",
+ });
+ });
+}
diff --git a/api/src/routes/offline-report-router.ts b/api/src/routes/offline-report-router.ts
index 03d0831..56cc715 100644
--- a/api/src/routes/offline-report-router.ts
+++ b/api/src/routes/offline-report-router.ts
@@ -26,9 +26,9 @@ const userService = new UserService();
offlineReportRouter.post("/", async (req: Request, res: Response) => {
const {} = req.body;
- let currentUserEmail = req.body.email;
+ let currentUserEmail = req.body.on_behalf_email;
let currentUserId = 1;
- let currentUserName = req.body.email;
+ let currentUserName = req.body.on_behalf_email;
const existingUser = await userService.getByEmail(currentUserEmail);
@@ -36,7 +36,11 @@ offlineReportRouter.post("/", async (req: Request, res: Response) => {
currentUserId = existingUser.id;
currentUserEmail = existingUser.email;
currentUserName = existingUser.display_name;
+
+ console.log("Using Existing user", req.body.on_behalf_email);
} else {
+ console.log("Creating new user", req.body.on_behalf_email);
+
const createdUser = await userService.create({
department: "",
division: "",
diff --git a/api/src/services/user-service.ts b/api/src/services/user-service.ts
index f47ed39..1706107 100644
--- a/api/src/services/user-service.ts
+++ b/api/src/services/user-service.ts
@@ -25,7 +25,7 @@ export class UserService {
async getByEmail(email: string): Promise {
if (email) {
- let user = await db("users").where({ email }).first();
+ let user = await db("users").whereRaw(`LOWER("email") = '${email.toLowerCase()}'`).first();
if (user) user.roles = await roleService.getRolesForUser(user.id);
return user;
}
diff --git a/web/public/serviceWorker.js b/web/public/serviceWorker.js
index 9082da4..8725675 100644
--- a/web/public/serviceWorker.js
+++ b/web/public/serviceWorker.js
@@ -66,7 +66,7 @@ registerRoute(
plugins: [
new ExpirationPlugin({
maxEntries: 16,
- maxAgeSeconds: 120,
+ maxAgeSeconds: 30 * 24 * 60, // 30 days
}),
],
})
diff --git a/web/src/components/incident/CreatePageOffline.vue b/web/src/components/incident/CreatePageOffline.vue
index 7ffdded..69f17a5 100644
--- a/web/src/components/incident/CreatePageOffline.vue
+++ b/web/src/components/incident/CreatePageOffline.vue
@@ -5,6 +5,11 @@
Incident investigation and corrective action. For further information, contant the Director of Health, Safety &
Wellbeing at 867-332-5974.
+
+
+
+
+
@@ -103,7 +108,7 @@
Your email
-
+
Supervisor's email
@@ -134,7 +139,7 @@ import { requiredRule, emailRule } from "@/utils/validation";
const reportStore = useReportStore();
const { initialize, addReportOffline } = reportStore;
-const { locations, urgencies } = storeToRefs(reportStore);
+const { locations, urgencies, isLoading } = storeToRefs(reportStore);
const isValid = ref(false);
diff --git a/web/src/store/ReportStore.ts b/web/src/store/ReportStore.ts
index 91af2fb..f621a05 100644
--- a/web/src/store/ReportStore.ts
+++ b/web/src/store/ReportStore.ts
@@ -9,6 +9,7 @@ export const useReportStore = defineStore("reports", {
locations: [] as Location[],
urgencies: [] as Urgency[],
selectedReport: undefined as Incident | undefined,
+ isLoading: false,
}),
actions: {
async initialize() {
@@ -89,6 +90,7 @@ export const useReportStore = defineStore("reports", {
async addReportOffline(report: Incident) {
console.log("ADDREPORTOFFLINE", report);
+ this.isLoading = true;
const api = useApiStore();
@@ -107,7 +109,9 @@ export const useReportStore = defineStore("reports", {
formData.append("files", file);
}
- return api.upload("post", `${OFFLINEREPORTS_URL}`, formData);
+ return api.upload("post", `${OFFLINEREPORTS_URL}`, formData).finally(() => {
+ this.isLoading = false;
+ });
/* const storedJson = this.getStoredReports();
storedJson.push(report);