Skip to content

Commit bb381b9

Browse files
authored
Merge pull request #24 from AmRo045/dev
Add ability to update password & README improvement
2 parents 55aa15d + 152d6e4 commit bb381b9

File tree

4 files changed

+76
-14
lines changed

4 files changed

+76
-14
lines changed

README.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,25 @@ Outline Admin is a web interface for the Outline Manager API, providing a simple
1313

1414
1. [Added Features](#added-features)
1515
2. [Installation](#installation)
16-
- [Using Docker](#installation---docker)
17-
- [Using Docker Compose](#using-docker-compose)
18-
- [Using NodeJS](#installation---nodejs)
16+
- [Docker](#docker)
17+
- [Docker Compose](#docker-compose)
18+
- [NodeJS](#nodejs)
1919
3. [Development](#development)
20-
4. [Donation](#donation)
21-
5. [Screenshots](#screenshots)
20+
4. [Admin Password](#admin-password)
21+
5. [Donation](#donation)
22+
6. [Screenshots](#screenshots)
2223

2324
## Added Features
2425

25-
- Set expiration dates for Access Keys.
26-
- Generate QR codes for Access Keys.
27-
- Create dynamic Access Keys.
28-
- Add prefix to Access Keys.
26+
- Expiration dates for Access Keys.
27+
- QR codes for Access Keys.
28+
- Dynamic Access Keys.
29+
- Access Key prefix.
2930

3031

3132
## Installation
3233

33-
### Installation - Docker
34+
### Docker
3435

3536
Before installing Outline Admin, ensure that Docker and Docker Compose are installed on your machine. Use the following commands to start the container:
3637

@@ -39,7 +40,7 @@ Before installing Outline Admin, ensure that Docker and Docker Compose are insta
3940
docker run -d -p 3000:3000 --name outline-admin -v ./oa_data:/app/data --restart unless-stopped amro045/outline-admin:latest
4041
```
4142

42-
#### Using Docker Compose
43+
#### Docker Compose
4344

4445
To simplify the installation, you can use a Docker Compose file:
4546

@@ -51,7 +52,7 @@ wget -O docker-compose.yml https://raw.githubusercontent.com/AmRo045/OutlineAdmi
5152
docker compose up -d
5253
```
5354

54-
### Installation - NodeJS
55+
### NodeJS
5556

5657
To run this project on your machine, ensure you have Node.js v20 or later and npm v10 or later installed.
5758
Follow the steps below to set up Outline Admin using Node.js:
@@ -130,6 +131,22 @@ npm run setup
130131
npm run dev
131132
```
132133

134+
## Admin Password
135+
136+
To update the admin user password, use one of the following commands.
137+
138+
For Docker containers:
139+
140+
```bash
141+
docker exec -it outline-admin npm run password:change "your new password"
142+
```
143+
144+
For non-Docker setup:
145+
146+
```bash
147+
npm run password:change "your new password"
148+
```
149+
133150
## Donation
134151

135152
If you find this project useful and would like to support its development, consider making a donation. Your support is greatly appreciated!

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "outline-admin",
3-
"version": "0.1.10",
3+
"version": "0.1.13",
44
"private": true,
55
"scripts": {
66
"compile": "tsc -p tsconfig.scripts.json && tscpaths -p tsconfig.scripts.tscpaths.json -s ./dist -o ./dist",
@@ -10,6 +10,7 @@
1010
"build:docker": "node ./dist/scripts/build.js",
1111
"start": "echo cd into .next/standalone and run node server.js",
1212
"start:docker": "node ./dist/scripts/start.js",
13+
"password:change": "node ./dist/scripts/change-password.js",
1314
"lint": "eslint ./scripts ./src --ext .ts,.tsx -c .eslintrc.json --fix",
1415
"format": "prettier --write ./src/**/*.{ts,tsx,json} ./scripts/**/*.{ts,tsx,json}",
1516
"format:check": "prettier --check ./src/**/*.{ts,tsx,json} ./scripts/**/*.{ts,tsx,json}",

scripts/change-password.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import bcrypt from "bcrypt";
2+
import prisma from "@/prisma/db";
3+
4+
const updatePassword = async (password: string): Promise<void> => {
5+
const hashedPassword = await bcrypt.hash(password, 10);
6+
7+
const adminUser = await prisma.user.findFirst();
8+
9+
if (adminUser) {
10+
await prisma.user.update({
11+
where: { id: adminUser.id },
12+
data: {
13+
password: hashedPassword
14+
}
15+
});
16+
} else {
17+
await prisma.user.create({
18+
data: {
19+
password: hashedPassword
20+
}
21+
});
22+
}
23+
};
24+
25+
const main = async () => {
26+
const args = process.argv.slice(2);
27+
const password = args[0];
28+
29+
if (!password) {
30+
console.error("Error: Password is required");
31+
process.exit(1);
32+
}
33+
34+
await updatePassword(password);
35+
36+
console.log("Password updated successfully.");
37+
};
38+
39+
main().catch((error) => {
40+
console.error("Unexpected error:", error);
41+
process.exit(1);
42+
});

src/core/outline/outline-sync-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/* eslint-disable no-console */
22
import { AccessKey, Server } from "@prisma/client";
33

4+
import { MAX_DATA_LIMIT_FOR_ACCESS_KEYS } from "../config";
5+
46
import prisma from "@/prisma/db";
57
import OutlineClient from "@/src/core/outline/outline-client";
68
import { DataLimitUnit, Outline } from "@/src/core/definitions";
7-
import { MAX_DATA_LIMIT_FOR_ACCESS_KEYS } from "../config";
89

910
export class OutlineSyncService {
1011
protected client: OutlineClient;
@@ -44,6 +45,7 @@ export class OutlineSyncService {
4445
where: { id: this.server.id },
4546
data: {
4647
name: remoteServerInfo.name,
48+
hostnameOrIp: remoteServerInfo.hostnameForAccessKeys,
4749
hostnameForNewAccessKeys: remoteServerInfo.hostnameForAccessKeys,
4850
portForNewAccessKeys: remoteServerInfo.portForNewAccessKeys,
4951
isMetricsEnabled: remoteServerInfo.metricsEnabled,

0 commit comments

Comments
 (0)