Skip to content

Commit 5b188eb

Browse files
committed
Bug fix: Entering credentials does not work and images won't load
1 parent 3f18b18 commit 5b188eb

File tree

11 files changed

+211
-313
lines changed

11 files changed

+211
-313
lines changed

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ android {
7878
applicationId "com.frigateviewer"
7979
minSdkVersion rootProject.ext.minSdkVersion
8080
targetSdkVersion rootProject.ext.targetSdkVersion
81-
versionCode 10
82-
versionName "1.3.1"
81+
versionCode 11
82+
versionName "1.3.2"
8383
}
8484
signingConfigs {
8585
debug {

helpers/rest.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
import { ToastAndroid } from 'react-native';
2-
import { Credentials } from '../store/settings';
1+
import {Buffer} from 'buffer';
2+
import {ToastAndroid} from 'react-native';
3+
import {Credentials} from '../store/settings';
4+
5+
export const authorizationHeader: (credentials: Credentials | null) => {
6+
Authorization?: string;
7+
} = credentials =>
8+
credentials !== null
9+
? {
10+
Authorization: `Basic ${Buffer.from(
11+
`${credentials.username}:${credentials.password}`,
12+
).toString('base64')}`,
13+
}
14+
: {};
315

416
export const get = async <T>(
517
endpoint: string,
@@ -12,7 +24,7 @@ export const get = async <T>(
1224
`${endpoint}${queryParams ? `?${new URLSearchParams(queryParams)}` : ''}`,
1325
{
1426
headers: {
15-
Authorization: credentials !== null ? `Basic ${Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64')}` : undefined,
27+
...authorizationHeader(credentials),
1628
},
1729
},
1830
).then(res => (json === false ? res.text() : res.json()));
@@ -35,7 +47,7 @@ export const post = async <T>(
3547
{
3648
method: 'post',
3749
headers: {
38-
Authorization: credentials !== null ? `Basic ${Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64')}` : undefined,
50+
...authorizationHeader(credentials),
3951
},
4052
},
4153
).then(res => (json === false ? res.text() : res.json()));
@@ -58,7 +70,7 @@ export const del = async <T>(
5870
{
5971
method: 'delete',
6072
headers: {
61-
Authorization: credentials !== null ? `Basic ${Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64')}` : undefined,
73+
...authorizationHeader(credentials),
6274
},
6375
},
6476
).then(res => (json === false ? res.text() : res.json()));

0 commit comments

Comments
 (0)