Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit 2ff10a6

Browse files
committed
feat(web): implement user authentication and add on the fly migration to Strapi's authentication
1 parent 4d3eaea commit 2ff10a6

File tree

15 files changed

+325
-46
lines changed

15 files changed

+325
-46
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ DATABASE_PASSWORD=super-secret
44
DATABASE_PORT=3306
55
DATABASE_SSL=false
66

7-
APP_DATABASE_NAME=vim
7+
WEB_DATABASE_NAME=vim
88
CMS_DATABASE_NAME=vim_cms
99

1010
CMS_PORT=1337

cms/src/extensions/users-permissions/strapi-server.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/user-migration/user-migration.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1+
// example migration
12
const strapiUrl = "http://localhost:1337/api";
2-
33
const axios = require("axios");
44

55
async function getUsersFromStrapi() {
66
try {
7-
// Make a GET request to the Strapi API to fetch users
87
const response = await axios.get(`${strapiUrl}/users`);
9-
10-
// Extract user data from the response
118
const users = response.data;
12-
13-
// Output user data
14-
console.log("Users:");
159
console.log(users);
1610
} catch (error) {
1711
console.error("Error fetching users:", error.message);
@@ -43,19 +37,16 @@ async function createUser(username, email, password, old_password) {
4337
}
4438
}
4539

46-
// Get the client
4740
const mysql = require("mysql2");
48-
// Create the connection to database
4941
const connection = mysql.createConnection({
5042
host: "localhost",
5143
user: "vim",
5244
database: "vim",
5345
password: "super-secret",
5446
});
5547

56-
// A simple SELECT query
5748
connection.query("SELECT * FROM `vs_users`", function (err, results, fields) {
58-
console.log(results); // results contains rows returned by server
49+
console.log(results);
5950

6051
results.forEach((user) => {
6152
createUser(user.user_name, user.email, "123gege321", "old_hash")
@@ -67,5 +58,5 @@ connection.query("SELECT * FROM `vs_users`", function (err, results, fields) {
6758
});
6859
});
6960

70-
console.log(fields); // fields contains extra meta data about results, if available
61+
console.log(fields);
7162
});

web/package-lock.json

Lines changed: 140 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"@tabler/icons-react": "^2.45.0",
1616
"@tanstack/react-table": "^8.11.7",
1717
"axios": "^1.6.8",
18+
"md5": "^2.3.0",
19+
"mysql2": "^3.9.7",
1820
"next": "13.5.6",
1921
"next-auth": "^4.24.7",
2022
"qs": "^6.11.2",
@@ -23,6 +25,7 @@
2325
"swiper": "^11.0.5"
2426
},
2527
"devDependencies": {
28+
"@types/md5": "^2.3.5",
2629
"@types/node": "^20",
2730
"@types/qs": "^6.9.11",
2831
"@types/react": "^18",

0 commit comments

Comments
 (0)