reset the ApiToken on password changes/resets (#15433)

* reset the ApiToken on password changes/resets

* fix/add tests

* fix(typo): test grammar

* update new API Token Strings, removed unused one

---------

Co-authored-by: Kalista Payne <sabrecat@gmail.com>
This commit is contained in:
negue
2025-07-01 19:30:34 +02:00
committed by GitHub
parent e68661c04b
commit 6fdc072ec3
12 changed files with 106 additions and 74 deletions

View File

@@ -1,9 +1,18 @@
import axios from 'axios';
import moment from 'moment';
export const LOCALSTORAGE_AUTH_KEY = 'habit-mobile-settings';
export function authAsCredentialsState (authObject) {
return {
API_ID: authObject.auth.apiId,
API_TOKEN: authObject.auth.apiToken,
};
}
export function setUpAxios (AUTH_SETTINGS) { // eslint-disable-line import/prefer-default-export
if (!AUTH_SETTINGS) {
AUTH_SETTINGS = localStorage.getItem('habit-mobile-settings'); // eslint-disable-line no-param-reassign, max-len
AUTH_SETTINGS = localStorage.getItem(LOCALSTORAGE_AUTH_KEY); // eslint-disable-line no-param-reassign, max-len
if (!AUTH_SETTINGS) return false;
AUTH_SETTINGS = JSON.parse(AUTH_SETTINGS); // eslint-disable-line no-param-reassign
}