Skip to content

Commit

Permalink
Added Roles to User APIs (#10)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
ct-dixit and phoenixcoded20 authored Oct 22, 2024
1 parent 920c308 commit e0b0866
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mock-data-api-nextjs",
"version": "1.1.0",
"version": "1.2.0",
"private": false,
"scripts": {
"dev": "next dev -p 3010",
Expand Down
14 changes: 8 additions & 6 deletions src/data/users.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[
{ "id": "5e86809283e28b96d2d38537", "email": "[email protected]", "password": "123456", "name": "JWT User" },
{ "id": "5e87809273e28b96d2e38538", "email": "[email protected]", "password": "123456", "name": "JWT User" },
{ "id": "344353656373", "email": "[email protected]", "password": "123456", "name": "Milan Bhikadiya" },
{ "id": "61d81b3d", "email": "[email protected]", "password": "123456", "name": "Milan Bhikadiya" },
{ "id": "774598e0", "email": "[email protected]", "password": "Test1234", "name": "New Test" },
{ "id": "9571bb3a", "email": "[email protected]", "password": "aA@123456", "name": "Amit Gorasiya" }
{ "id": "5e86809283e28b96d2d38537", "email": "[email protected]", "password": "123456", "name": "JWT User", "role": "Admin" },
{ "id": "5e87809273e28b96d2e38538", "email": "[email protected]", "password": "123456", "name": "JWT User", "role": "Admin" },
{ "id": "344353656373", "email": "[email protected]", "password": "123456", "name": "Milan Bhikadiya", "role": "Admin" },
{ "id": "61d81b3d", "email": "[email protected]", "password": "123456", "name": "Milan Bhikadiya", "role": "Admin" },
{ "id": "774598e0", "email": "[email protected]", "password": "Test1234", "name": "New Test", "role": "Admin" },
{ "id": "9571bb3a", "email": "[email protected]", "password": "aA@123456", "name": "Amit Gorasiya", "role": "Admin" },
{ "id": "5648ww9g", "email": "[email protected]", "password": "Admin@123", "name": "Admin User", "role": "Admin" },
{ "id": "9654cc9d", "email": "[email protected]", "password": "User@123", "name": "John Challis", "role": "User" }
]
3 changes: 2 additions & 1 deletion src/pages/api/account/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default async function handler(req, res) {
user: {
id: user.id,
email: user.email,
name: user.name
name: user.name,
role: user.role
}
});
}
3 changes: 2 additions & 1 deletion src/pages/api/account/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default async function handler(req, res) {
id,
email,
password,
name: `${firstName} ${lastName}`
name: `${firstName} ${lastName}`,
role: 'User'
};

users.push(user);
Expand Down

0 comments on commit e0b0866

Please sign in to comment.