From a381dde2e9028975359c7eb9c1855a90b87be7db Mon Sep 17 00:00:00 2001 From: iamshobhraj Date: Wed, 20 Nov 2024 01:38:11 +0530 Subject: [PATCH 1/8] moved login/logout logic into useUser composable --- packages/kolibri/composables/useUser.js | 182 ++++++++++++++++++------ 1 file changed, 141 insertions(+), 41 deletions(-) diff --git a/packages/kolibri/composables/useUser.js b/packages/kolibri/composables/useUser.js index 88f59f4816c..d7a17ee9ce0 100644 --- a/packages/kolibri/composables/useUser.js +++ b/packages/kolibri/composables/useUser.js @@ -1,39 +1,143 @@ -import { computed } from '@vue/composition-api'; -import store from 'kolibri/store'; +import { ref, computed } from '@vue/composition-api'; +import client from 'kolibri/client'; +import urls from 'kolibri/urls'; +import redirectBrowser from 'kolibri/utils/redirectBrowser'; +import CatchErrors from 'kolibri/utils/CatchErrors'; +import Lockr from 'lockr'; +import some from 'lodash/some'; +import pick from 'lodash/pick'; +import { setServerTime } from 'kolibri/utils/serverClock'; +import { + UserKinds, + ERROR_CONSTANTS, + LoginErrors, + UPDATE_MODAL_DISMISSED +} from 'kolibri/constants'; +import { browser, os } from 'kolibri/utils/browserInfo'; + +// Module level state +const session = ref({ + app_context: false, + can_manage_content: false, + facility_id: undefined, + full_name: '', + id: undefined, + kind: [UserKinds.ANONYMOUS], + user_id: undefined, + username: '', + full_facility_import: true, +}); export default function useUser() { - //getters - const isUserLoggedIn = computed(() => store.getters.isUserLoggedIn); - const currentUserId = computed(() => store.getters.currentUserId); - const isLearnerOnlyImport = computed(() => store.getters.isLearnerOnlyImport); - const isCoach = computed(() => store.getters.isCoach); - const isAdmin = computed(() => store.getters.isAdmin); - const isSuperuser = computed(() => store.getters.isSuperuser); - const canManageContent = computed(() => store.getters.canManageContent); - const isAppContext = computed(() => store.getters.isAppContext); - const isClassCoach = computed(() => store.getters.isClassCoach); - const isFacilityCoach = computed(() => store.getters.isFacilityCoach); - const isLearner = computed(() => store.getters.isLearner); - const isFacilityAdmin = computed(() => store.getters.isFacilityAdmin); - const userIsMultiFacilityAdmin = computed(() => store.getters.userIsMultiFacilityAdmin); - const getUserPermissions = computed(() => store.getters.getUserPermissions); - const userFacilityId = computed(() => store.getters.userFacilityId); - const getUserKind = computed(() => store.getters.getUserKind); - const userHasPermissions = computed(() => store.getters.userHasPermissions); - const session = computed(() => store.getters.session); + // Computed properties (former Vuex getters) + const isUserLoggedIn = computed(() => session.value.id !== undefined); + const currentUserId = computed(() => session.value.user_id); + const isLearnerOnlyImport = computed(() => !session.value.full_facility_import); + const isCoach = computed(() => + session.value.kind.some(kind => + [UserKinds.COACH, UserKinds.ASSIGNABLE_COACH].includes(kind) + ) + ); + const isAdmin = computed(() => + session.value.kind.some(kind => + [UserKinds.ADMIN, UserKinds.SUPERUSER].includes(kind) + ) + ); + const isSuperuser = computed(() => session.value.kind.includes(UserKinds.SUPERUSER)); + const canManageContent = computed(() => + session.value.kind.includes(UserKinds.CAN_MANAGE_CONTENT) + ); + const isAppContext = computed(() => session.value.app_context); + const isClassCoach = computed(() => session.value.kind.includes(UserKinds.ASSIGNABLE_COACH)); + const isFacilityCoach = computed(() => session.value.kind.includes(UserKinds.COACH)); + const isFacilityAdmin = computed(() => session.value.kind.includes(UserKinds.ADMIN)); + const userIsMultiFacilityAdmin = computed((rootState) => + isSuperuser.value && rootState.core.facilities.length > 1); + const getUserPermissions = computed(() => { + const permissions = {}; + permissions.can_manage_content = canManageContent.value; + return permissions; + }); + const isLearner = computed(() => session.value.kind.includes(UserKinds.LEARNER)); + const userFacilityId = computed(() => session.value.facility_id); + const getUserKind = computed(() => session.value.kind[0]); + const userHasPermissions = computed(() => some(getUserPermissions.value)); + + + // Actions + async function kolibriLogin(sessionPayload) { + Lockr.set(UPDATE_MODAL_DISMISSED, false); + + try { + await client({ + data: { + ...sessionPayload, + active: true, + browser, + os, + }, + url: urls['kolibri:core:session-list'](), + method: 'post', + }); + + if (!sessionPayload.disableRedirect) { + if (sessionPayload.next) { + redirectBrowser(sessionPayload.next); + } else { + redirectBrowser(); + } + } + } catch (error) { + const errorsCaught = CatchErrors(error, [ + ERROR_CONSTANTS.INVALID_CREDENTIALS, + ERROR_CONSTANTS.MISSING_PASSWORD, + ERROR_CONSTANTS.PASSWORD_NOT_SPECIFIED, + ERROR_CONSTANTS.NOT_FOUND, + ]); + + if (errorsCaught) { + if (errorsCaught.includes(ERROR_CONSTANTS.INVALID_CREDENTIALS)) { + return LoginErrors.INVALID_CREDENTIALS; + } else if (errorsCaught.includes(ERROR_CONSTANTS.MISSING_PASSWORD)) { + return LoginErrors.PASSWORD_MISSING; + } else if (errorsCaught.includes(ERROR_CONSTANTS.PASSWORD_NOT_SPECIFIED)) { + return LoginErrors.PASSWORD_NOT_SPECIFIED; + } else if (errorsCaught.includes(ERROR_CONSTANTS.NOT_FOUND)) { + return LoginErrors.USER_NOT_FOUND; + } + } + throw error; + } + } - //state - const app_context = computed(() => store.getters.session.app_context); - const can_manage_content = computed(() => store.getters.session.can_manage_content); - const facility_id = computed(() => store.getters.session.facility_id); - const full_name = computed(() => store.getters.session.full_name); - const id = computed(() => store.getters.session.id); - const kind = computed(() => store.getters.session.kind); - const user_id = computed(() => store.getters.session.user_id); - const full_facility_import = computed(() => store.getters.session.full_facility_import); - const username = computed(() => store.getters.session.username); + function kolibriLogout() { + redirectBrowser(urls['kolibri:core:logout']()); + } + + function setSession({ session: newSession, clientNow }) { + const serverTime = newSession.server_time; + if (clientNow) { + setServerTime(serverTime, clientNow); + } + const filteredSession = pick(newSession, Object.keys(session)); + session.value = { + ...session.value, + ...filteredSession, + }; + } + + + async function kolibrisetUnspecifiedPassword({ username, password, facility }) { + return client({ + url: urls['kolibri:core:setnonspecifiedpassword'](), + data: { username, password, facility }, + method: 'post', + }); + } return { + + // Computed isLearnerOnlyImport, isUserLoggedIn, currentUserId, @@ -52,15 +156,11 @@ export default function useUser() { getUserKind, userHasPermissions, session, - //state - app_context, - can_manage_content, - facility_id, - full_name, - id, - kind, - user_id, - username, - full_facility_import, + + // Actions + kolibriLogin, + kolibriLogout, + setSession, + kolibrisetUnspecifiedPassword, }; } From edf5aee820a9d3c07f57fa65725ba110e5a57558 Mon Sep 17 00:00:00 2001 From: iamshobhraj Date: Fri, 6 Dec 2024 04:53:40 +0530 Subject: [PATCH 2/8] updated references to CORE_SET_SESSION and changed it to the new composition API useUser --- packages/kolibri/__tests__/heartbeat.spec.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/kolibri/__tests__/heartbeat.spec.js b/packages/kolibri/__tests__/heartbeat.spec.js index 1e2a286d569..2d2d03b02a5 100644 --- a/packages/kolibri/__tests__/heartbeat.spec.js +++ b/packages/kolibri/__tests__/heartbeat.spec.js @@ -1,27 +1,26 @@ import mock from 'xhr-mock'; -import coreStore from 'kolibri/store'; import redirectBrowser from 'kolibri/utils/redirectBrowser'; import * as serverClock from 'kolibri/utils/serverClock'; import { get, set } from '@vueuse/core'; import useSnackbar, { useSnackbarMock } from 'kolibri/composables/useSnackbar'; // eslint-disable-line import { ref } from '@vue/composition-api'; import { DisconnectionErrorCodes } from 'kolibri/constants'; +import useUser, { useUserMock } from 'kolibri/composables/useUser'; // eslint-disable-line import { HeartBeat } from '../heartbeat.js'; import { trs } from '../internal/disconnection'; -import coreModule from '../../../kolibri/core/assets/src/state/modules/core'; import { stubWindowLocation } from 'testUtils'; // eslint-disable-line jest.mock('kolibri/utils/redirectBrowser'); jest.mock('kolibri/urls'); jest.mock('lockr'); jest.mock('kolibri/composables/useSnackbar'); +jest.mock('kolibri/composables/useUser'); -coreStore.registerModule('core', coreModule); describe('HeartBeat', function () { stubWindowLocation(beforeAll, afterAll); // replace the real XHR object with the mock XHR object before each test - beforeEach(() => mock.setup()); + beforeEach(() => useUser.mockImplementation(() => useUserMock())); // put the real XHR object back and clear the mocks after each test afterEach(() => mock.teardown()); @@ -206,7 +205,8 @@ describe('HeartBeat', function () { jest.spyOn(heartBeat, '_sessionUrl').mockReturnValue('url'); }); it('should sign out if an auto logout is detected', function () { - coreStore.commit('CORE_SET_SESSION', { user_id: 'test', id: 'current' }); + const { setSession } = useUser(); + setSession({ session: { user_id: 'test', id: 'current' } }); mock.put(/.*/, { status: 200, body: JSON.stringify({ user_id: null, id: 'current' }), @@ -218,7 +218,8 @@ describe('HeartBeat', function () { }); }); it('should redirect if a change in user is detected', function () { - coreStore.commit('CORE_SET_SESSION', { user_id: 'test', id: 'current' }); + const { setSession } = useUser(); + setSession({ session: { user_id: 'test', id: 'current' } }); redirectBrowser.mockReset(); mock.put(/.*/, { status: 200, @@ -230,7 +231,8 @@ describe('HeartBeat', function () { }); }); it('should not sign out if user_id changes but session is being set for first time', function () { - coreStore.commit('CORE_SET_SESSION', { user_id: undefined, id: undefined }); + const { setSession } = useUser(); + setSession({ session: { user_id: undefined, id: undefined } }); mock.put(/.*/, { status: 200, body: JSON.stringify({ user_id: null, id: 'current' }), @@ -242,7 +244,8 @@ describe('HeartBeat', function () { }); }); it('should call setServerTime with a clientNow value that is between the start and finish of the poll', function () { - coreStore.commit('CORE_SET_SESSION', { user_id: 'test', id: 'current' }); + const { setSession } = useUser(); + setSession({ session: { user_id: 'test', id: 'current' } }); const serverTime = new Date().toJSON(); mock.put(/.*/, { status: 200, From 8f5d63d477b01d398ecac5d744244ac6494cff06 Mon Sep 17 00:00:00 2001 From: iamshobhraj Date: Fri, 6 Dec 2024 04:55:02 +0530 Subject: [PATCH 3/8] updated useUser mock file as per the new compostion api --- .../kolibri/composables/__mocks__/useUser.js | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/kolibri/composables/__mocks__/useUser.js b/packages/kolibri/composables/__mocks__/useUser.js index c179ee9273c..22ee2feb5af 100644 --- a/packages/kolibri/composables/__mocks__/useUser.js +++ b/packages/kolibri/composables/__mocks__/useUser.js @@ -30,10 +30,11 @@ * useUser.mockImplementation(() => useUserMock()) * ``` */ -import { computed } from '@vue/composition-api'; -import { UserKinds } from 'kolibri/constants'; + import { ref, computed } from '@vue/composition-api'; + import { UserKinds } from 'kolibri/constants'; + import { jest } from '@jest/globals'; // Ensure jest is imported for mocking functions -const session = { +const MOCK_DEFAULT_SESSION = { app_context: false, can_manage_content: false, facility_id: undefined, @@ -63,9 +64,9 @@ const MOCK_DEFAULTS = { userFacilityId: undefined, getUserKind: UserKinds.ANONYMOUS, userHasPermissions: false, - session, - //state - ...session, + session: { ...MOCK_DEFAULT_SESSION }, + // Mock state + ...MOCK_DEFAULT_SESSION, }; export function useUserMock(overrides = {}) { @@ -77,7 +78,29 @@ export function useUserMock(overrides = {}) { for (const key in mocks) { computedMocks[key] = computed(() => mocks[key]); } - return computedMocks; + + // Module-level state reference for actions + const session = ref({ ...mocks.session }); + + // Mock implementation of `useUser` methods + return { + ...computedMocks, + session, // Make session mutable for test scenarios + + // Actions + setSession: jest.fn(({ session: newSession, clientNow }) => { + session.value = { + ...MOCK_DEFAULT_SESSION, + ...newSession, + }; + }), + + kolibriLogin: jest.fn(async () => Promise.resolve()), + + kolibriLogout: jest.fn(() => {}), + + kolibrisetUnspecifiedPassword: jest.fn(async () => Promise.resolve()), + }; } export default jest.fn(() => useUserMock()); From b5647baeb48179b37e234489e68bbe33bfde23f8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 12:53:10 +0000 Subject: [PATCH 4/8] [pre-commit.ci lite] apply automatic fixes --- packages/kolibri/__tests__/heartbeat.spec.js | 1 - .../kolibri/composables/__mocks__/useUser.js | 6 ++--- packages/kolibri/composables/useUser.js | 25 ++++++------------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/packages/kolibri/__tests__/heartbeat.spec.js b/packages/kolibri/__tests__/heartbeat.spec.js index 2d2d03b02a5..dc587647034 100644 --- a/packages/kolibri/__tests__/heartbeat.spec.js +++ b/packages/kolibri/__tests__/heartbeat.spec.js @@ -16,7 +16,6 @@ jest.mock('lockr'); jest.mock('kolibri/composables/useSnackbar'); jest.mock('kolibri/composables/useUser'); - describe('HeartBeat', function () { stubWindowLocation(beforeAll, afterAll); // replace the real XHR object with the mock XHR object before each test diff --git a/packages/kolibri/composables/__mocks__/useUser.js b/packages/kolibri/composables/__mocks__/useUser.js index 22ee2feb5af..5f024c81746 100644 --- a/packages/kolibri/composables/__mocks__/useUser.js +++ b/packages/kolibri/composables/__mocks__/useUser.js @@ -30,9 +30,9 @@ * useUser.mockImplementation(() => useUserMock()) * ``` */ - import { ref, computed } from '@vue/composition-api'; - import { UserKinds } from 'kolibri/constants'; - import { jest } from '@jest/globals'; // Ensure jest is imported for mocking functions +import { ref, computed } from '@vue/composition-api'; +import { UserKinds } from 'kolibri/constants'; +import { jest } from '@jest/globals'; // Ensure jest is imported for mocking functions const MOCK_DEFAULT_SESSION = { app_context: false, diff --git a/packages/kolibri/composables/useUser.js b/packages/kolibri/composables/useUser.js index d7a17ee9ce0..bb398f5df66 100644 --- a/packages/kolibri/composables/useUser.js +++ b/packages/kolibri/composables/useUser.js @@ -7,12 +7,7 @@ import Lockr from 'lockr'; import some from 'lodash/some'; import pick from 'lodash/pick'; import { setServerTime } from 'kolibri/utils/serverClock'; -import { - UserKinds, - ERROR_CONSTANTS, - LoginErrors, - UPDATE_MODAL_DISMISSED -} from 'kolibri/constants'; +import { UserKinds, ERROR_CONSTANTS, LoginErrors, UPDATE_MODAL_DISMISSED } from 'kolibri/constants'; import { browser, os } from 'kolibri/utils/browserInfo'; // Module level state @@ -34,25 +29,22 @@ export default function useUser() { const currentUserId = computed(() => session.value.user_id); const isLearnerOnlyImport = computed(() => !session.value.full_facility_import); const isCoach = computed(() => - session.value.kind.some(kind => - [UserKinds.COACH, UserKinds.ASSIGNABLE_COACH].includes(kind) - ) + session.value.kind.some(kind => [UserKinds.COACH, UserKinds.ASSIGNABLE_COACH].includes(kind)), ); const isAdmin = computed(() => - session.value.kind.some(kind => - [UserKinds.ADMIN, UserKinds.SUPERUSER].includes(kind) - ) + session.value.kind.some(kind => [UserKinds.ADMIN, UserKinds.SUPERUSER].includes(kind)), ); const isSuperuser = computed(() => session.value.kind.includes(UserKinds.SUPERUSER)); const canManageContent = computed(() => - session.value.kind.includes(UserKinds.CAN_MANAGE_CONTENT) + session.value.kind.includes(UserKinds.CAN_MANAGE_CONTENT), ); const isAppContext = computed(() => session.value.app_context); const isClassCoach = computed(() => session.value.kind.includes(UserKinds.ASSIGNABLE_COACH)); const isFacilityCoach = computed(() => session.value.kind.includes(UserKinds.COACH)); const isFacilityAdmin = computed(() => session.value.kind.includes(UserKinds.ADMIN)); - const userIsMultiFacilityAdmin = computed((rootState) => - isSuperuser.value && rootState.core.facilities.length > 1); + const userIsMultiFacilityAdmin = computed( + rootState => isSuperuser.value && rootState.core.facilities.length > 1, + ); const getUserPermissions = computed(() => { const permissions = {}; permissions.can_manage_content = canManageContent.value; @@ -63,7 +55,6 @@ export default function useUser() { const getUserKind = computed(() => session.value.kind[0]); const userHasPermissions = computed(() => some(getUserPermissions.value)); - // Actions async function kolibriLogin(sessionPayload) { Lockr.set(UPDATE_MODAL_DISMISSED, false); @@ -126,7 +117,6 @@ export default function useUser() { }; } - async function kolibrisetUnspecifiedPassword({ username, password, facility }) { return client({ url: urls['kolibri:core:setnonspecifiedpassword'](), @@ -136,7 +126,6 @@ export default function useUser() { } return { - // Computed isLearnerOnlyImport, isUserLoggedIn, From ade4e399dc16c62ddc9179ef71d2a8546bb0191a Mon Sep 17 00:00:00 2001 From: iamshobhraj Date: Tue, 10 Dec 2024 02:00:10 +0530 Subject: [PATCH 5/8] added 'mock.setup' in 'beforeEach' --- packages/kolibri/__tests__/heartbeat.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/kolibri/__tests__/heartbeat.spec.js b/packages/kolibri/__tests__/heartbeat.spec.js index 2d2d03b02a5..61d23a819b6 100644 --- a/packages/kolibri/__tests__/heartbeat.spec.js +++ b/packages/kolibri/__tests__/heartbeat.spec.js @@ -20,7 +20,11 @@ jest.mock('kolibri/composables/useUser'); describe('HeartBeat', function () { stubWindowLocation(beforeAll, afterAll); // replace the real XHR object with the mock XHR object before each test - beforeEach(() => useUser.mockImplementation(() => useUserMock())); + + beforeEach(() => { + mock.setup(); + useUser.mockImplementation(() => useUserMock()); + }); // put the real XHR object back and clear the mocks after each test afterEach(() => mock.teardown()); From 0355e8f85d26fdf6efaad069b71d0e475460d136 Mon Sep 17 00:00:00 2001 From: iamshobhraj Date: Tue, 10 Dec 2024 18:19:14 +0530 Subject: [PATCH 6/8] removed existing vuex methods --- .../assets/src/state/modules/core/actions.js | 61 +------------------ 1 file changed, 3 insertions(+), 58 deletions(-) diff --git a/kolibri/core/assets/src/state/modules/core/actions.js b/kolibri/core/assets/src/state/modules/core/actions.js index 24f000ddae9..23ab05e0649 100644 --- a/kolibri/core/assets/src/state/modules/core/actions.js +++ b/kolibri/core/assets/src/state/modules/core/actions.js @@ -67,14 +67,7 @@ export function handleApiError(store, { error, reloadOnReconnect = false } = {}) throw error; } -export function setSession(store, { session, clientNow }) { - const serverTime = session.server_time; - if (clientNow) { - setServerTime(serverTime, clientNow); - } - session = pick(session, Object.keys(baseSessionState)); - store.commit('CORE_SET_SESSION', session); -} + /** * Sets a password that is currently not specified @@ -103,57 +96,9 @@ export function kolibriSetUnspecifiedPassword(store, { username, password, facil * @param {object} store The store. * @param {object} sessionPayload The session payload. */ -export function kolibriLogin(store, sessionPayload) { - Lockr.set(UPDATE_MODAL_DISMISSED, false); - return client({ - data: { - ...sessionPayload, - active: true, - browser, - os, - }, - url: urls['kolibri:core:session_list'](), - method: 'post', - }) - .then(() => { - // check redirect is disabled: - if (!sessionPayload.disableRedirect) - if (sessionPayload.next) { - // OIDC redirect - redirectBrowser(sessionPayload.next); - } - // Normal redirect on login - else { - redirectBrowser(); - } - }) - .catch(error => { - const errorsCaught = CatchErrors(error, [ - ERROR_CONSTANTS.INVALID_CREDENTIALS, - ERROR_CONSTANTS.MISSING_PASSWORD, - ERROR_CONSTANTS.PASSWORD_NOT_SPECIFIED, - ERROR_CONSTANTS.NOT_FOUND, - ]); - if (errorsCaught) { - if (errorsCaught.includes(ERROR_CONSTANTS.INVALID_CREDENTIALS)) { - return LoginErrors.INVALID_CREDENTIALS; - } else if (errorsCaught.includes(ERROR_CONSTANTS.MISSING_PASSWORD)) { - return LoginErrors.PASSWORD_MISSING; - } else if (errorsCaught.includes(ERROR_CONSTANTS.PASSWORD_NOT_SPECIFIED)) { - return LoginErrors.PASSWORD_NOT_SPECIFIED; - } else if (errorsCaught.includes(ERROR_CONSTANTS.NOT_FOUND)) { - return LoginErrors.USER_NOT_FOUND; - } - } else { - store.dispatch('handleApiError', { error }); - } - }); -} -export function kolibriLogout() { - // Use the logout backend URL to initiate logout - redirectBrowser(urls['kolibri:core:logout']()); -} + + const _setPageVisibility = debounce((store, visibility) => { store.commit('CORE_SET_PAGE_VISIBILITY', visibility); From f78ae8df53b8e797840cee492c873f643ebac4e3 Mon Sep 17 00:00:00 2001 From: iamshobhraj Date: Tue, 10 Dec 2024 18:31:32 +0530 Subject: [PATCH 7/8] refactored store.dispatch with setSession mutation --- packages/kolibri/heartbeat.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/kolibri/heartbeat.js b/packages/kolibri/heartbeat.js index 5806a32a3fe..d8d8415945d 100644 --- a/packages/kolibri/heartbeat.js +++ b/packages/kolibri/heartbeat.js @@ -161,7 +161,7 @@ export class HeartBeat { * @return {Promise} promise that resolves when the endpoint check is complete. */ _checkSession() { - const { id, currentUserId } = useUser(); + const { id, currentUserId, setSession } = useUser(); // Record the current user id to check if a different one is returned by the server. if (!get(this._connection.connected)) { // If not currently connected to the server, flag that we are currently trying to reconnect. @@ -196,17 +196,8 @@ export class HeartBeat { redirectBrowser(); } } - store.dispatch('setSession', { - session, - // Calculate an approximation of the client 'now' that was simultaneous to the server - // 'now' that was sent back with the request. We calculate this as the mean of the - // start of the request and the end of the request, which assumes that the calculation - // of the local_now on the server side happens at the midpoint of the request response - // cycle. Evidently this is not completely accurate, but it is the best that we can do. - // Further, this fails to account for relativity, as simultaneity depends on your specific - // frame of reference. If the client is moving relative to the server at speeds - // approaching the speed of light, this may produce some odd results, - // but I think that was always true. + setSession({ + session: session, clientNow: new Date((pollEnd + pollStart) / 2), }); }) From ec7851aa405df9e32f819ad44cd488128408854b Mon Sep 17 00:00:00 2001 From: iamshobhraj Date: Tue, 10 Dec 2024 18:51:09 +0530 Subject: [PATCH 8/8] removed existing vuex methods --- .../assets/src/state/modules/core/actions.js | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/kolibri/core/assets/src/state/modules/core/actions.js b/kolibri/core/assets/src/state/modules/core/actions.js index 23ab05e0649..191b8791045 100644 --- a/kolibri/core/assets/src/state/modules/core/actions.js +++ b/kolibri/core/assets/src/state/modules/core/actions.js @@ -67,39 +67,6 @@ export function handleApiError(store, { error, reloadOnReconnect = false } = {}) throw error; } - - -/** - * Sets a password that is currently not specified - * due to an account that was created while passwords - * were not required. - * - * @param {object} store The store. - * @param {object} sessionPayload The session payload. - */ -export function kolibriSetUnspecifiedPassword(store, { username, password, facility }) { - const data = { - username, - password, - facility, - }; - return client({ - url: urls['kolibri:core:setnonspecifiedpassword'](), - data, - method: 'post', - }); -} - -/** - * Signs in user. - * - * @param {object} store The store. - * @param {object} sessionPayload The session payload. - */ - - - - const _setPageVisibility = debounce((store, visibility) => { store.commit('CORE_SET_PAGE_VISIBILITY', visibility); }, 500);