Skip to content

Commit e040fd1

Browse files
committed
Fix display of database rows when password is not available
closes pterodactyl#4381
1 parent bf2456d commit e040fd1

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

resources/scripts/api/server/databases/getServerDatabases.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ export const rawDataToServerDatabase = (data: any): ServerDatabase => ({
1515
username: data.username,
1616
connectionString: `${data.host.address}:${data.host.port}`,
1717
allowConnectionsFrom: data.connections_from,
18-
password:
19-
data.relationships && data.relationships.password ? data.relationships.password.attributes.password : undefined,
18+
password: data.relationships.password?.attributes?.password,
2019
});
2120

2221
export default (uuid: string, includePassword = true): Promise<ServerDatabase[]> => {

resources/scripts/components/server/databases/DatabaseRow.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export default ({ database, className }: Props) => {
3434
const appendDatabase = ServerContext.useStoreActions((actions) => actions.databases.appendDatabase);
3535
const removeDatabase = ServerContext.useStoreActions((actions) => actions.databases.removeDatabase);
3636

37+
const jdbcConnectionString = `jdbc:mysql://${database.username}${
38+
database.password ? `:${database.password}` : ''
39+
}@${database.connectionString}/${database.name}`;
40+
3741
const schema = object().shape({
3842
confirm: string()
3943
.required('The database name must be provided.')
@@ -122,14 +126,8 @@ export default ({ database, className }: Props) => {
122126
</Can>
123127
<div css={tw`mt-6`}>
124128
<Label>JDBC Connection String</Label>
125-
<CopyOnClick
126-
text={`jdbc:mysql://${database.username}:${database.password}@${database.connectionString}/${database.name}`}
127-
>
128-
<Input
129-
type={'text'}
130-
readOnly
131-
value={`jdbc:mysql://${database.username}:${database.password}@${database.connectionString}/${database.name}`}
132-
/>
129+
<CopyOnClick text={jdbcConnectionString}>
130+
<Input type={'text'} readOnly value={jdbcConnectionString} />
133131
</CopyOnClick>
134132
</div>
135133
<div css={tw`mt-6 text-right`}>

0 commit comments

Comments
 (0)