aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-29 10:58:24 +0200
committerChocobozzz <me@florianbigard.com>2018-03-29 11:03:30 +0200
commit490b595a01c5824ff63ffb87f0efdfca95f4bf3b (patch)
tree3ad716fbb97a8b4ee946ad907202b82934a33d7c /client/src/app
parent23f4c3d412974fa5fda52589d1192e098e260f1a (diff)
downloadPeerTube-490b595a01c5824ff63ffb87f0efdfca95f4bf3b.tar.gz
PeerTube-490b595a01c5824ff63ffb87f0efdfca95f4bf3b.tar.zst
PeerTube-490b595a01c5824ff63ffb87f0efdfca95f4bf3b.zip
Prevent brute force login attack
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/core/auth/auth.service.ts8
-rw-r--r--client/src/app/shared/rest/rest-extractor.service.ts36
-rw-r--r--client/src/app/signup/signup.component.ts2
3 files changed, 29 insertions, 17 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index f5ca2fcdc..d31c61496 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -66,8 +66,12 @@ export class AuthService {
66 }, 66 },
67 67
68 error => { 68 error => {
69 let errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n` 69 let errorMessage = error.message
70 errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.' 70
71 if (error.status === 403) {
72 errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n`
73 errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.'
74 }
71 75
72 // We put a bigger timeout 76 // We put a bigger timeout
73 // This is an important message 77 // This is an important message
diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts
index ad08a32f8..b1e22a76c 100644
--- a/client/src/app/shared/rest/rest-extractor.service.ts
+++ b/client/src/app/shared/rest/rest-extractor.service.ts
@@ -42,25 +42,33 @@ export class RestExtractor {
42 console.error('An error occurred:', errorMessage) 42 console.error('An error occurred:', errorMessage)
43 } else if (err.status !== undefined) { 43 } else if (err.status !== undefined) {
44 // A server-side error occurred. 44 // A server-side error occurred.
45 if (err.error) { 45 if (err.error && err.error.errors) {
46 if (err.error.errors) { 46 const errors = err.error.errors
47 const errors = err.error.errors 47 const errorsArray: string[] = []
48 const errorsArray: string[] = [] 48
49 49 Object.keys(errors).forEach(key => {
50 Object.keys(errors).forEach(key => { 50 errorsArray.push(errors[key].msg)
51 errorsArray.push(errors[key].msg) 51 })
52 }) 52
53 53 errorMessage = errorsArray.join('. ')
54 errorMessage = errorsArray.join('. ') 54 } else if (err.error && err.error.error) {
55 } else if (err.error.error) { 55 errorMessage = err.error.error
56 errorMessage = err.error.error
57 }
58 } else if (err.status === 413) { 56 } else if (err.status === 413) {
59 errorMessage = 'Request is too large for the server. Please contact you administrator if you want to increase the limit size.' 57 errorMessage = 'Request is too large for the server. Please contact you administrator if you want to increase the limit size.'
58 } else if (err.status === 429) {
59 const secondsLeft = err.headers.get('retry-after')
60 if (secondsLeft) {
61 const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60)
62 errorMessage = 'Too many attempts, please try again after ' + minutesLeft + ' minutes.'
63 } else {
64 errorMessage = 'Too many attempts, please try again later.'
65 }
66 } else if (err.status === 500) {
67 errorMessage = 'Server error. Please retry later.'
60 } 68 }
61 69
62 errorMessage = errorMessage ? errorMessage : 'Unknown error.' 70 errorMessage = errorMessage ? errorMessage : 'Unknown error.'
63 console.error(`Backend returned code ${err.status}, body was: ${errorMessage}`) 71 console.error(`Backend returned code ${err.status}, errorMessage is: ${errorMessage}`)
64 } else { 72 } else {
65 errorMessage = err 73 errorMessage = err
66 } 74 }
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts
index 93d73a11e..1f3e2e146 100644
--- a/client/src/app/signup/signup.component.ts
+++ b/client/src/app/signup/signup.component.ts
@@ -101,7 +101,7 @@ export class SignupComponent extends FormReactive implements OnInit {
101 const lines = [ 101 const lines = [
102 SignupComponent.getApproximateTime(fullHdSeconds) + ' of full HD videos', 102 SignupComponent.getApproximateTime(fullHdSeconds) + ' of full HD videos',
103 SignupComponent.getApproximateTime(hdSeconds) + ' of HD videos', 103 SignupComponent.getApproximateTime(hdSeconds) + ' of HD videos',
104 SignupComponent.getApproximateTime(normalSeconds) + ' of normal quality videos' 104 SignupComponent.getApproximateTime(normalSeconds) + ' of average quality videos'
105 ] 105 ]
106 106
107 this.quotaHelpIndication = lines.join('<br />') 107 this.quotaHelpIndication = lines.join('<br />')