aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/config/edit-custom-config
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-22 15:29:32 +0100
committerChocobozzz <me@florianbigard.com>2018-02-22 15:29:32 +0100
commit1f30a1853e38c20a45722dbd6d38aaaec63839e8 (patch)
treecdce8cc9fcc62d9b3343c9478b1dbcefedcea972 /client/src/app/+admin/config/edit-custom-config
parent78967fca4cacbc247fa6fb62d64b2d6825a10804 (diff)
downloadPeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.tar.gz
PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.tar.zst
PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.zip
Add confirm when admin use custom js/css
Diffstat (limited to 'client/src/app/+admin/config/edit-custom-config')
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts32
1 files changed, 30 insertions, 2 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index 027268536..ccec89a8e 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms' 2import { FormBuilder, FormGroup } from '@angular/forms'
3import { Router } from '@angular/router' 3import { Router } from '@angular/router'
4import { ConfigService } from '@app/+admin/config/shared/config.service' 4import { ConfigService } from '@app/+admin/config/shared/config.service'
5import { ConfirmService } from '@app/core'
5import { ServerService } from '@app/core/server/server.service' 6import { ServerService } from '@app/core/server/server.service'
6import { FormReactive, USER_VIDEO_QUOTA } from '@app/shared' 7import { FormReactive, USER_VIDEO_QUOTA } from '@app/shared'
7import { 8import {
@@ -61,12 +62,16 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
61 userVideoQuota: USER_VIDEO_QUOTA.MESSAGES 62 userVideoQuota: USER_VIDEO_QUOTA.MESSAGES
62 } 63 }
63 64
65 private oldCustomJavascript: string
66 private oldCustomCSS: string
67
64 constructor ( 68 constructor (
65 private formBuilder: FormBuilder, 69 private formBuilder: FormBuilder,
66 private router: Router, 70 private router: Router,
67 private notificationsService: NotificationsService, 71 private notificationsService: NotificationsService,
68 private configService: ConfigService, 72 private configService: ConfigService,
69 private serverService: ServerService 73 private serverService: ServerService,
74 private confirmService: ConfirmService
70 ) { 75 ) {
71 super() 76 super()
72 } 77 }
@@ -109,6 +114,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
109 res => { 114 res => {
110 this.customConfig = res 115 this.customConfig = res
111 116
117 this.oldCustomCSS = this.customConfig.instance.customizations.css
118 this.oldCustomJavascript = this.customConfig.instance.customizations.javascript
119
112 this.updateForm() 120 this.updateForm()
113 }, 121 },
114 122
@@ -124,7 +132,27 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
124 return this.form.value['signupEnabled'] === true 132 return this.form.value['signupEnabled'] === true
125 } 133 }
126 134
127 formValidated () { 135 async formValidated () {
136 const newCustomizationJavascript = this.form.value['customizationJavascript']
137 const newCustomizationCSS = this.form.value['customizationCSS']
138
139 const customizations = []
140 if (newCustomizationJavascript && newCustomizationJavascript !== this.oldCustomJavascript) customizations.push('JavaScript')
141 if (newCustomizationCSS && newCustomizationCSS !== this.oldCustomCSS) customizations.push('CSS')
142
143 if (customizations.length !== 0) {
144 const customizationsText = customizations.join('/')
145
146 const message = `You set custom ${customizationsText}. ` +
147 'This could lead to security issues or bugs if you do not understand it. ' +
148 'Are you sure you want to update the configuration?'
149 const label = `Please type "I understand the ${customizationsText} I set" to confirm.`
150 const expectedInputValue = `I understand the ${customizationsText} I set`
151
152 const confirmRes = await this.confirmService.confirmWithInput(message, label, expectedInputValue)
153 if (confirmRes === false) return
154 }
155
128 const data = { 156 const data = {
129 instance: { 157 instance: {
130 name: this.form.value['instanceName'], 158 name: this.form.value['instanceName'],