-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
372 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
cms/src/extensions/users-permissions/content-types/user/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"kind": "collectionType", | ||
"collectionName": "up_users", | ||
"info": { | ||
"name": "user", | ||
"description": "", | ||
"singularName": "user", | ||
"pluralName": "users", | ||
"displayName": "User" | ||
}, | ||
"options": { | ||
"draftAndPublish": false | ||
}, | ||
"attributes": { | ||
"username": { | ||
"type": "string", | ||
"minLength": 3, | ||
"unique": true, | ||
"configurable": false, | ||
"required": true | ||
}, | ||
"email": { | ||
"type": "email", | ||
"minLength": 6, | ||
"configurable": false, | ||
"required": true | ||
}, | ||
"provider": { | ||
"type": "string", | ||
"configurable": false | ||
}, | ||
"password": { | ||
"type": "password", | ||
"minLength": 6, | ||
"configurable": false, | ||
"private": true, | ||
"searchable": false | ||
}, | ||
"resetPasswordToken": { | ||
"type": "string", | ||
"configurable": false, | ||
"private": true, | ||
"searchable": false | ||
}, | ||
"confirmationToken": { | ||
"type": "string", | ||
"configurable": false, | ||
"private": true, | ||
"searchable": false | ||
}, | ||
"confirmed": { | ||
"type": "boolean", | ||
"default": false, | ||
"configurable": false | ||
}, | ||
"blocked": { | ||
"type": "boolean", | ||
"default": false, | ||
"configurable": false | ||
}, | ||
"role": { | ||
"type": "relation", | ||
"relation": "manyToOne", | ||
"target": "plugin::users-permissions.role", | ||
"inversedBy": "users", | ||
"configurable": false | ||
}, | ||
"old_pw_hash": { | ||
"type": "string" | ||
}, | ||
"migrated_pw": { | ||
"type": "boolean", | ||
"default": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = plugin => { | ||
const x = | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "user-migration", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "user-migration.js", | ||
"scripts": { | ||
"migrate": "node user-migration.js" | ||
}, | ||
"author": "izzy", | ||
"license": "ISC", | ||
"dependencies": { | ||
"axios": "^1.6.8", | ||
"mysql2": "^3.9.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const strapiUrl = "http://localhost:1337/api"; | ||
|
||
const axios = require("axios"); | ||
|
||
async function getUsersFromStrapi() { | ||
try { | ||
// Make a GET request to the Strapi API to fetch users | ||
const response = await axios.get(`${strapiUrl}/users`); | ||
|
||
// Extract user data from the response | ||
const users = response.data; | ||
|
||
// Output user data | ||
console.log("Users:"); | ||
console.log(users); | ||
} catch (error) { | ||
console.error("Error fetching users:", error.message); | ||
} | ||
} | ||
|
||
async function createUser(username, email, password, old_password) { | ||
try { | ||
const response = await fetch(`${strapiUrl}/auth/local/register`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
username: username, | ||
email: email, | ||
password: password, | ||
old_pw_hash: old_password, | ||
}), | ||
}); | ||
console.log(response); | ||
|
||
return await response.json(); | ||
} catch (e) { | ||
console.log("something went wrong"); | ||
console.log(e); | ||
return null; | ||
} | ||
} | ||
|
||
// Get the client | ||
const mysql = require("mysql2"); | ||
// Create the connection to database | ||
const connection = mysql.createConnection({ | ||
host: "localhost", | ||
user: "vim", | ||
database: "vim", | ||
password: "super-secret", | ||
}); | ||
|
||
// A simple SELECT query | ||
connection.query("SELECT * FROM `vs_users`", function (err, results, fields) { | ||
console.log(results); // results contains rows returned by server | ||
|
||
results.forEach((user) => { | ||
createUser(user.user_name, user.email, "123gege321", "old_hash") | ||
.then((a) => { | ||
console.log(a); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
}); | ||
|
||
console.log(fields); // fields contains extra meta data about results, if available | ||
}); |