Add error when email system is not configured and using the forgot

password system
pull/1462/head
Chocobozzz 2018-12-05 15:10:45 +01:00
parent 56af5222c1
commit 3b3b18203f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 28 additions and 6 deletions

View File

@ -37,6 +37,9 @@ export class ServerService {
css: ''
}
},
email: {
enabled: false
},
serverVersion: 'Unknown',
signup: {
allowed: false,

View File

@ -59,7 +59,12 @@
</div>
<div class="modal-body">
<div class="form-group">
<div *ngIf="isEmailDisabled()" class="alert alert-danger" i18n>
We are sorry, you cannot recover you password because your instance administrator did not configure the PeerTube email system.
</div>
<div class="form-group" [hidden]="isEmailDisabled()">
<label i18n for="forgot-password-email">Email</label>
<input
type="email" id="forgot-password-email" i18n-placeholder placeholder="Email address" required

View File

@ -19,7 +19,6 @@ import { Router } from '@angular/router'
export class LoginComponent extends FormReactive implements OnInit {
@ViewChild('emailInput') input: ElementRef
@ViewChild('forgotPasswordModal') forgotPasswordModal: ElementRef
@ViewChild('forgotPasswordEmailInput') forgotPasswordEmailInput: ElementRef
error: string = null
forgotPasswordEmail = ''
@ -45,6 +44,10 @@ export class LoginComponent extends FormReactive implements OnInit {
return this.serverService.getConfig().signup.allowed === true
}
isEmailDisabled () {
return this.serverService.getConfig().email.enabled === false
}
ngOnInit () {
this.buildForm({
username: this.loginValidatorsService.LOGIN_USERNAME,
@ -96,10 +99,6 @@ export class LoginComponent extends FormReactive implements OnInit {
)
}
onForgotPasswordModalShown () {
this.forgotPasswordEmailInput.nativeElement.focus()
}
openForgotPasswordModal () {
this.openedForgotPasswordModal = this.modalService.open(this.forgotPasswordModal)
}

View File

@ -11,6 +11,7 @@ import { ClientHtml } from '../../lib/client-html'
import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger'
import { remove, writeJSON } from 'fs-extra'
import { getServerCommit } from '../../helpers/utils'
import { Emailer } from '../../lib/emailer'
const packageJSON = require('../../../../package.json')
const configRouter = express.Router()
@ -61,6 +62,9 @@ async function getConfig (req: express.Request, res: express.Response) {
css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS
}
},
email: {
enabled: Emailer.Instance.isEnabled()
},
serverVersion: packageJSON.version,
serverCommit,
signup: {

View File

@ -14,6 +14,7 @@ class Emailer {
private static instance: Emailer
private initialized = false
private transporter: Transporter
private enabled = false
private constructor () {}
@ -50,6 +51,8 @@ class Emailer {
tls,
auth
})
this.enabled = true
} else {
if (!isTestInstance()) {
logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!')
@ -57,6 +60,10 @@ class Emailer {
}
}
isEnabled () {
return this.enabled
}
async checkConnectionOrDie () {
if (!this.transporter) return

View File

@ -15,6 +15,10 @@ export interface ServerConfig {
}
}
email: {
enabled: boolean
}
signup: {
allowed: boolean,
allowedForCurrentIP: boolean,