Skip to content

Commit 505562e

Browse files
Add readme.md file for the utility of AssignRoleToUserForADay
1 parent 59fe6b6 commit 505562e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Utility/readme.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Utility: AssignRoleToUserForADay.js
2+
3+
## Overview
4+
`AssignRoleToUserForADay.js` is a utility script designed to temporarily assign a role to a user for a single day. This can be useful for granting temporary permissions or access within an application.
5+
6+
## Features
7+
- Assign a role to a user for 24 hours.
8+
- Automatically revoke the role after the time period expires.
9+
- Log actions for auditing purposes.
10+
11+
## Usage
12+
1. **Import the script**:
13+
```javascript
14+
var assignRoleToUserForADay = require('./Utility/AssignRoleToUserForADay');
15+
```
16+
17+
2. **Call the function**:
18+
```javascript
19+
assignRoleToUserForADay(userId, roleId)
20+
.then(() => {
21+
console.log('Role assigned successfully.');
22+
})
23+
.catch((error) => {
24+
console.error('Error assigning role:', error);
25+
});
26+
```
27+
28+
## Parameters
29+
- `userId` (String): The ID of the user to whom the role will be assigned.
30+
- `roleId` (String): The ID of the role to be assigned.
31+
32+
## Example
33+
```javascript
34+
var assignRoleToUserForADay = require('./Utility/AssignRoleToUserForADay');
35+
36+
var userId = '12345';
37+
var roleId = 'admin';
38+
39+
assignRoleToUserForADay(userId, roleId)
40+
.then(() => {
41+
console.log('Role assigned successfully.');
42+
})
43+
.catch((error) => {
44+
console.error('Error assigning role:', error);
45+
});
46+
```

0 commit comments

Comments
 (0)