if I role the creds bac?

This commit is contained in:
Violet Caulfield
2024-10-20 10:07:09 -05:00
parent e5c428f958
commit b24a68f11a
3 changed files with 12 additions and 3 deletions
+8 -2
View File
@@ -6,6 +6,7 @@ import { JellifyServer } from "../../../types/JellifyServer";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { AsyncStorageKeys } from "../../../enums/async-storage-keys";
import { buildApiClient } from "../../client";
import _ from "lodash";
interface ServerMutationParams {
serverUrl: string,
@@ -28,6 +29,11 @@ export const mutateServer = async (server: JellifyServer | undefined) => {
return await AsyncStorage.setItem(AsyncStorageKeys.ServerUrl, JSON.stringify(server));
}
export const mutateServerCredentials = async (credentials: JellyfinCredentials) => {
return Keychain.setInternetCredentials((await fetchServer()).url, credentials.username, credentials.accessToken!);
export const mutateServerCredentials = async (credentials?: JellyfinCredentials) => {
if (!_.isUndefined(credentials)) {
return Keychain.setInternetCredentials((await fetchServer()).url, credentials.username, credentials.accessToken!);
}
return Keychain.resetInternetCredentials((await fetchServer()).url);
}
View File