Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade strapi versions #65

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ We'll run this docker-compose command to get MongoDB running. (This may take a w
$ docker-compose up -d
```

The `-d` tells docker to run in the background, later if we want to see logs from the db we can use:
The `-d` tells docker to run in the background, later if we want to see logs from the db we can use:

```sh
docker-compose logs --tail
Expand All @@ -70,6 +70,17 @@ We'll need to make a copy of the `.env` file:
$ cp .env.example .env
```

We'll need to generate two secure token for the authentication systems.
```sh
$ node -e "console.log(require('crypto').randomBytes(64).toString('base64'))"
```

Add the generated value to your env variables in the `.env` file.
```sh
JWT_SECRET=token_generated_from_above
ADMIN_JWT_SECRET=second_token_generated_from_above
```

Finally to run the backend app and initialize some config in the db, we'll install the dependencies and run the server:

```sh
Expand Down
7 changes: 5 additions & 2 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
HOST=0.0.0.0
PORT=1337
ADMIN_USERNAME=admin
ADMIN_PASSWORD=test
[email protected]
ADMIN_PASSWORD=test

# See README for instructions on generating secure tokens
ADMIN_JWT_SECRET=
JWT_SECRET=
4 changes: 4 additions & 0 deletions server/.strapi-updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"latest": "3.4.5",
"lastUpdateCheck": 1612048152510
}
14 changes: 9 additions & 5 deletions server/config/functions/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,21 @@ module.exports = async () => {
};

async function initializeAdmin() {
const adminModel = strapi.query("administrator", "admin");
const admin = await adminModel.findOne({ username: "admin" });
const admin = await strapi.query("user", "admin").findOne({ username: "admin" });

if (!admin) {
strapi.log.info(`creating admin user`);
await adminModel.create({
username: process.env.ADMIN_USERNAME,

const superAdminRole = await strapi.admin.services.role.getSuperAdmin();

await strapi.query("user", "admin").create({
username: 'admin',
email: process.env.ADMIN_EMAIL,
password: await strapi.admin.services.auth.hashPassword(
process.env.ADMIN_PASSWORD
),
email: process.env.ADMIN_EMAIL,
roles: [superAdminRole.id],
isActive: true,
});
}
}
Expand Down
3 changes: 3 additions & 0 deletions server/config/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module.exports = ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
watchIgnoreFiles: ["**/db/**"],
},
});
5 changes: 5 additions & 0 deletions server/extensions/users-permissions/models/User.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
"configurable": false,
"private": true
},
"confirmationToken": {
"type": "string",
"configurable": false,
"private": true
},
"confirmed": {
"type": "boolean",
"default": false,
Expand Down
Loading