Skip to content

Commit

Permalink
Merge branch 'master-pre' into features/code-injection-PRE
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele Panico committed Oct 16, 2024
2 parents 21dc5a2 + e2c6f32 commit 0004e09
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,27 @@
### **Copyrigth**:
*Tiledesk SRL*

# 1.22.0-rc.1
- **added**: role guard to main root

# 1.21.0

# 1.21.0-rc.16
- **added**: doc for new actions

# 1.21.0-rc.15
- **added**: image preload resolve for doc images
- **changed**: info-tooltip doc component UI

# 1.21.0-rc.14
- **added**: changed: min value for max_tokens if citations checkbox is enabled

# 1.21.0-rc.13
- **added**: 'connect_block', 'move_to_unassigned' and 'clear_transcript' actions
- **added**: chatbot_id system-defined variable
- **added**: enable 'connect_block' action only if present in project.profile


# 1.21.0-rc.12
- **added**: formatType checkbox in action gpt-task
- **added**: citations in action askkbv2
Expand Down
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,7 +1,7 @@
{
"name": "@tiledesk/cds",
"author": "Tiledesk SRL",
"version": "1.21.0",
"version": "1.22.0-rc.1",
"license": "MIT",
"homepage": "https://www.tiledesk.com",
"repository": {
Expand Down
3 changes: 2 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const routes: Routes = [

{ path: 'project/:projectid/chatbot/:faqkbid',
loadChildren: () => import('./chatbot-design-studio/cds-dashboard/cds-dashboard.module').then( m => m.CdsDashboardModule),
canActivate:[AuthGuard, RoleGuard]
canActivate:[AuthGuard, RoleGuard],
data: [ { roles: ['owner', 'admin']}]
},

// Wildcard route for a 404 page
Expand Down
13 changes: 10 additions & 3 deletions src/app/guards/role.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
export class RoleGuard implements CanActivate {

private logger: LoggerService = LoggerInstance.getInstance();

private roles: Array<string> = [];
private projectUser: ProjectUser;

constructor(
private appStorageService: AppStorageService,
private tiledeskAuthService: TiledeskAuthService,
Expand All @@ -27,6 +29,7 @@ export class RoleGuard implements CanActivate {
const url = state.url;
const _url = route['_routerState'].url

this.roles = route.data[0].roles
/** CHECK USER IS LOGGED IN */
const queryParams = route.queryParams['jwt']

Expand All @@ -44,8 +47,11 @@ export class RoleGuard implements CanActivate {
/** CHECK USER IS IN CURRENT PROJET */
const projectId= route.params.projectid
const user = this.tiledeskAuthService.getCurrentUser()
const userIsInProject = await this.getProjectUserInProject(projectId, user.uid)
if(!userIsInProject){
//step 1: check if user is in project as a projectUser
const userIsInProject = await this.getProjectUserInProject(projectId, user.uid)
//step 2: check if projectUser has the correct enabled role for current path
const roleEnabled = this.roles.includes(this.projectUser.role);
if(!userIsInProject || !roleEnabled){
this.router.navigate([`project/unauthorized`]);
return false
}
Expand All @@ -57,6 +63,7 @@ export class RoleGuard implements CanActivate {
getProjectUserInProject(projectId: string, userId: string): Promise<boolean>{
return new Promise((resolve, reject)=> {
this.projectsService.getProjectUserByUserId(projectId, userId).subscribe({ next: (projectUser: ProjectUser) => {
this.projectUser = projectUser
resolve(true)
}, error: (error)=> {
this.logger.error('[ROLE-GUARD] getProjectUserRole --> ERROR:', error)
Expand Down
Binary file modified src/assets/images/doc/AGENT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0004e09

Please sign in to comment.