mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
Changed HASH_SALT to APP_SECRET.
This commit is contained in:
parent
cad0b73e42
commit
7bbed0e12b
2
app.json
2
app.json
@ -6,7 +6,7 @@
|
|||||||
"repository": "https://github.com/umami-software/umami",
|
"repository": "https://github.com/umami-software/umami",
|
||||||
"addons": ["heroku-postgresql"],
|
"addons": ["heroku-postgresql"],
|
||||||
"env": {
|
"env": {
|
||||||
"HASH_SALT": {
|
"APP_SECRET": {
|
||||||
"description": "Used to generate unique values for your installation",
|
"description": "Used to generate unique values for your installation",
|
||||||
"required": true,
|
"required": true,
|
||||||
"generator": "secret"
|
"generator": "secret"
|
||||||
|
@ -2,11 +2,10 @@ import { SubmitButton, Form, FormInput, FormRow, FormButtons, TextField } from '
|
|||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import useApi from 'hooks/useApi';
|
import useApi from 'hooks/useApi';
|
||||||
import { getClientAuthToken } from 'lib/client';
|
|
||||||
import { DOMAIN_REGEX } from 'lib/constants';
|
import { DOMAIN_REGEX } from 'lib/constants';
|
||||||
|
|
||||||
export default function WebsiteEditForm({ websiteId, data, onSave }) {
|
export default function WebsiteEditForm({ websiteId, data, onSave }) {
|
||||||
const { post } = useApi(getClientAuthToken());
|
const { post } = useApi();
|
||||||
const { mutate, error } = useMutation(data => post(`/websites/${websiteId}`, data));
|
const { mutate, error } = useMutation(data => post(`/websites/${websiteId}`, data));
|
||||||
const ref = useRef(null);
|
const ref = useRef(null);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
DATABASE_URL: postgresql://umami:umami@db:5432/umami
|
DATABASE_URL: postgresql://umami:umami@db:5432/umami
|
||||||
DATABASE_TYPE: postgresql
|
DATABASE_TYPE: postgresql
|
||||||
HASH_SALT: replace-me-with-a-random-string
|
APP_SECRET: replace-me-with-a-random-string
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
restart: always
|
restart: always
|
||||||
|
@ -1,71 +1,13 @@
|
|||||||
import { useCallback } from 'react';
|
import { useApi as nextUseApi } from 'next-basics';
|
||||||
|
import { getClientAuthToken } from 'lib/client';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { get, post, put, del, getItem } from 'next-basics';
|
|
||||||
import { AUTH_TOKEN, SHARE_TOKEN_HEADER } from 'lib/constants';
|
|
||||||
import useStore from 'store/app';
|
|
||||||
|
|
||||||
const selector = state => state.shareToken;
|
export function useApi() {
|
||||||
|
|
||||||
function parseHeaders(headers, { authToken, shareToken }) {
|
|
||||||
if (authToken) {
|
|
||||||
headers.authorization = `Bearer ${authToken}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shareToken) {
|
|
||||||
headers[SHARE_TOKEN_HEADER] = shareToken.token;
|
|
||||||
}
|
|
||||||
|
|
||||||
return headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function useApi() {
|
|
||||||
const { basePath } = useRouter();
|
const { basePath } = useRouter();
|
||||||
const authToken = getItem(AUTH_TOKEN);
|
|
||||||
const shareToken = useStore(selector);
|
|
||||||
|
|
||||||
return {
|
const { get, post, put, del } = nextUseApi(getClientAuthToken(), basePath);
|
||||||
get: useCallback(
|
|
||||||
async (url, params = {}, headers = {}) => {
|
|
||||||
return get(
|
|
||||||
`${basePath}/api${url}`,
|
|
||||||
params,
|
|
||||||
parseHeaders(headers, { authToken, shareToken }),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
[get],
|
|
||||||
),
|
|
||||||
|
|
||||||
post: useCallback(
|
return { get, post, put, del };
|
||||||
async (url, params = {}, headers = {}) => {
|
|
||||||
return post(
|
|
||||||
`${basePath}/api${url}`,
|
|
||||||
params,
|
|
||||||
parseHeaders(headers, { authToken, shareToken }),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
[post],
|
|
||||||
),
|
|
||||||
|
|
||||||
put: useCallback(
|
|
||||||
async (url, params = {}, headers = {}) => {
|
|
||||||
return put(
|
|
||||||
`${basePath}/api${url}`,
|
|
||||||
params,
|
|
||||||
parseHeaders(headers, { authToken, shareToken }),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
[put],
|
|
||||||
),
|
|
||||||
|
|
||||||
del: useCallback(
|
|
||||||
async (url, params = {}, headers = {}) => {
|
|
||||||
return del(
|
|
||||||
`${basePath}/api${url}`,
|
|
||||||
params,
|
|
||||||
parseHeaders(headers, { authToken, shareToken }),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
[del],
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default useApi;
|
||||||
|
@ -3,7 +3,7 @@ import { startOfMonth } from 'date-fns';
|
|||||||
import { hash } from 'next-basics';
|
import { hash } from 'next-basics';
|
||||||
|
|
||||||
export function secret() {
|
export function secret() {
|
||||||
return hash(process.env.HASH_SALT || process.env.DATABASE_URL);
|
return hash(process.env.APP_SECRET || process.env.DATABASE_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function salt() {
|
export function salt() {
|
||||||
|
Loading…
Reference in New Issue
Block a user