Skip to content

Commit e0b0866

Browse files
Added Roles to User APIs (#10)
* Role base change in login and register page and also create two new login user * Update package.json * Update package-lock.json --------- Co-authored-by: CodedThemes <[email protected]>
1 parent 920c308 commit e0b0866

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mock-data-api-nextjs",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"private": false,
55
"scripts": {
66
"dev": "next dev -p 3010",

src/data/users.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
[
2-
{ "id": "5e86809283e28b96d2d38537", "email": "[email protected]", "password": "123456", "name": "JWT User" },
3-
{ "id": "5e87809273e28b96d2e38538", "email": "[email protected]", "password": "123456", "name": "JWT User" },
4-
{ "id": "344353656373", "email": "[email protected]", "password": "123456", "name": "Milan Bhikadiya" },
5-
{ "id": "61d81b3d", "email": "[email protected]", "password": "123456", "name": "Milan Bhikadiya" },
6-
{ "id": "774598e0", "email": "[email protected]", "password": "Test1234", "name": "New Test" },
7-
{ "id": "9571bb3a", "email": "[email protected]", "password": "aA@123456", "name": "Amit Gorasiya" }
2+
{ "id": "5e86809283e28b96d2d38537", "email": "[email protected]", "password": "123456", "name": "JWT User", "role": "Admin" },
3+
{ "id": "5e87809273e28b96d2e38538", "email": "[email protected]", "password": "123456", "name": "JWT User", "role": "Admin" },
4+
{ "id": "344353656373", "email": "[email protected]", "password": "123456", "name": "Milan Bhikadiya", "role": "Admin" },
5+
{ "id": "61d81b3d", "email": "[email protected]", "password": "123456", "name": "Milan Bhikadiya", "role": "Admin" },
6+
{ "id": "774598e0", "email": "[email protected]", "password": "Test1234", "name": "New Test", "role": "Admin" },
7+
{ "id": "9571bb3a", "email": "[email protected]", "password": "aA@123456", "name": "Amit Gorasiya", "role": "Admin" },
8+
{ "id": "5648ww9g", "email": "[email protected]", "password": "Admin@123", "name": "Admin User", "role": "Admin" },
9+
{ "id": "9654cc9d", "email": "[email protected]", "password": "User@123", "name": "John Challis", "role": "User" }
810
]

src/pages/api/account/login.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export default async function handler(req, res) {
2929
user: {
3030
id: user.id,
3131
email: user.email,
32-
name: user.name
32+
name: user.name,
33+
role: user.role
3334
}
3435
});
3536
}

src/pages/api/account/register.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export default async function handler(req, res) {
2323
id,
2424
email,
2525
password,
26-
name: `${firstName} ${lastName}`
26+
name: `${firstName} ${lastName}`,
27+
role: 'User'
2728
};
2829

2930
users.push(user);

0 commit comments

Comments
 (0)